drivers/gpu/drm/rockchip/rockchip_lvds.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/rockchip/rockchip_lvds.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/rockchip/rockchip_lvds.c
Extension
.c
Size
19599 bytes
Lines
718
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct rockchip_lvds_soc_data {
	int (*probe)(struct platform_device *pdev, struct rockchip_lvds *lvds);
	const struct drm_encoder_helper_funcs *helper_funcs;
};

struct rockchip_lvds {
	struct device *dev;
	void __iomem *regs;
	struct regmap *grf;
	struct clk *pclk;
	struct phy *dphy;
	const struct rockchip_lvds_soc_data *soc_data;
	int output; /* rgb lvds or dual lvds output */
	int format; /* vesa or jeida format */
	struct drm_device *drm_dev;
	struct drm_panel *panel;
	struct drm_bridge *bridge;
	struct rockchip_encoder encoder;
	struct dev_pin_info *pins;
};

static inline struct rockchip_lvds *brige_to_lvds(struct drm_bridge *bridge)
{
	return (struct rockchip_lvds *)bridge->driver_private;
}

static inline struct rockchip_lvds *encoder_to_lvds(struct drm_encoder *encoder)
{
	struct rockchip_encoder *rkencoder = to_rockchip_encoder(encoder);

	return container_of(rkencoder, struct rockchip_lvds, encoder);
}

static inline void rk3288_writel(struct rockchip_lvds *lvds, u32 offset,
				 u32 val)
{
	writel_relaxed(val, lvds->regs + offset);
	if (lvds->output == DISPLAY_OUTPUT_LVDS)
		return;
	writel_relaxed(val, lvds->regs + offset + RK3288_LVDS_CH1_OFFSET);
}

static inline int rockchip_lvds_name_to_format(const char *s)
{
	if (strncmp(s, "jeida-18", 8) == 0)
		return LVDS_JEIDA_18;
	else if (strncmp(s, "jeida-24", 8) == 0)
		return LVDS_JEIDA_24;
	else if (strncmp(s, "vesa-24", 7) == 0)
		return LVDS_VESA_24;

	return -EINVAL;
}

static inline int rockchip_lvds_name_to_output(const char *s)
{
	if (strncmp(s, "rgb", 3) == 0)
		return DISPLAY_OUTPUT_RGB;
	else if (strncmp(s, "lvds", 4) == 0)
		return DISPLAY_OUTPUT_LVDS;
	else if (strncmp(s, "duallvds", 8) == 0)
		return DISPLAY_OUTPUT_DUAL_LVDS;

	return -EINVAL;
}

static int
rockchip_lvds_bridge_get_modes(struct drm_bridge *bridge, struct drm_connector *connector)
{
	struct rockchip_lvds *lvds = brige_to_lvds(bridge);
	struct drm_panel *panel = lvds->panel;

	return drm_panel_get_modes(panel, connector);
}

static const
struct drm_bridge_funcs rockchip_lvds_bridge_funcs = {
	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
	.atomic_reset = drm_atomic_helper_bridge_reset,
	.get_modes = rockchip_lvds_bridge_get_modes,
};

static int
rockchip_lvds_encoder_atomic_check(struct drm_encoder *encoder,
				   struct drm_crtc_state *crtc_state,
				   struct drm_connector_state *conn_state)
{
	struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc_state);

Annotation

Implementation Notes