drivers/gpu/drm/imx/ipuv3/imx-ldb.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/imx/ipuv3/imx-ldb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/imx/ipuv3/imx-ldb.c- Extension
.c- Size
- 17119 bytes
- Lines
- 645
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/component.hlinux/i2c.hlinux/media-bus-format.hlinux/mfd/syscon.hlinux/mfd/syscon/imx6q-iomuxc-gpr.hlinux/module.hlinux/of.hlinux/of_graph.hlinux/platform_device.hlinux/property.hlinux/regmap.hlinux/videodev2.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_bridge_connector.hdrm/drm_managed.hdrm/drm_of.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/drm_simple_kms_helper.hdrm/bridge/of-display-mode-bridge.himx-drm.h
Detected Declarations
struct imx_ldb_channelstruct imx_ldb_encoderstruct imx_ldbstruct imx_ldb_channelstruct bus_muxstruct imx_ldbstruct imx_ldb_bit_mappingfunction imx_ldb_ch_set_bus_formatfunction imx_ldb_set_clockfunction imx_ldb_encoder_enablefunction imx_ldb_encoder_atomic_mode_setfunction imx_ldb_encoder_disablefunction imx_ldb_encoder_atomic_checkfunction imx_ldb_get_clkfunction imx_ldb_registerfunction of_get_bus_formatfunction imx_ldb_bindfunction imx_ldb_probefunction for_each_child_of_nodefunction imx_ldb_remove
Annotated Snippet
struct imx_ldb_encoder {
struct drm_encoder encoder;
struct imx_ldb_channel *channel;
};
struct imx_ldb;
struct imx_ldb_channel {
struct imx_ldb *ldb;
struct drm_bridge *bridge;
struct device_node *child;
int chno;
u32 bus_format;
};
static inline struct imx_ldb_channel *enc_to_imx_ldb_ch(struct drm_encoder *e)
{
return container_of(e, struct imx_ldb_encoder, encoder)->channel;
}
struct bus_mux {
int reg;
int shift;
int mask;
};
struct imx_ldb {
struct regmap *regmap;
struct device *dev;
struct imx_ldb_channel channel[2];
struct clk *clk[2]; /* our own clock */
struct clk *clk_sel[4]; /* parent of display clock */
struct clk *clk_parent[4]; /* original parent of clk_sel */
struct clk *clk_pll[2]; /* upstream clock we can adjust */
u32 ldb_ctrl;
const struct bus_mux *lvds_mux;
};
static void imx_ldb_ch_set_bus_format(struct imx_ldb_channel *imx_ldb_ch,
u32 bus_format)
{
struct imx_ldb *ldb = imx_ldb_ch->ldb;
int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
switch (bus_format) {
case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
break;
case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
if (imx_ldb_ch->chno == 0 || dual)
ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24;
if (imx_ldb_ch->chno == 1 || dual)
ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24;
break;
case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
if (imx_ldb_ch->chno == 0 || dual)
ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH0_24 |
LDB_BIT_MAP_CH0_JEIDA;
if (imx_ldb_ch->chno == 1 || dual)
ldb->ldb_ctrl |= LDB_DATA_WIDTH_CH1_24 |
LDB_BIT_MAP_CH1_JEIDA;
break;
}
}
static void imx_ldb_set_clock(struct imx_ldb *ldb, int mux, int chno,
unsigned long serial_clk, unsigned long di_clk)
{
int ret;
dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__,
clk_get_rate(ldb->clk_pll[chno]), serial_clk);
clk_set_rate(ldb->clk_pll[chno], serial_clk);
dev_dbg(ldb->dev, "%s after: %ld\n", __func__,
clk_get_rate(ldb->clk_pll[chno]));
dev_dbg(ldb->dev, "%s: now: %ld want: %ld\n", __func__,
clk_get_rate(ldb->clk[chno]),
(long int)di_clk);
clk_set_rate(ldb->clk[chno], di_clk);
dev_dbg(ldb->dev, "%s after: %ld\n", __func__,
clk_get_rate(ldb->clk[chno]));
/* set display clock mux to LDB input clock */
ret = clk_set_parent(ldb->clk_sel[mux], ldb->clk[chno]);
if (ret)
dev_err(ldb->dev,
Annotation
- Immediate include surface: `linux/clk.h`, `linux/component.h`, `linux/i2c.h`, `linux/media-bus-format.h`, `linux/mfd/syscon.h`, `linux/mfd/syscon/imx6q-iomuxc-gpr.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct imx_ldb_channel`, `struct imx_ldb_encoder`, `struct imx_ldb`, `struct imx_ldb_channel`, `struct bus_mux`, `struct imx_ldb`, `struct imx_ldb_bit_mapping`, `function imx_ldb_ch_set_bus_format`, `function imx_ldb_set_clock`, `function imx_ldb_encoder_enable`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.