Skip to content

RGB order override for DPI #6156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arch/arm/boot/dts/overlays/README
Original file line number Diff line number Diff line change
Expand Up @@ -4988,6 +4988,10 @@ Params: clock-frequency Display clock frequency (Hz)
Set the default brightness. Normal range 1-16.
(default 16).
rotate Display rotation {0,90,180,270} (default 0)
rgb-order Allow override of RGB order from DPI.
Options for vc4 are "rgb", "bgr", "grb", and
"brg". Other values will be ignored.



Name: vc4-kms-dpi-hyperpixel2r
Expand Down
1 change: 1 addition & 0 deletions arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@
rgb888 = <&panel_generic>, "bus-format:0=0x100a",
<&dpi_node_generic>, "pinctrl-0:0=",<&dpi_gpio0>;
bus-format = <&panel_generic>, "bus-format:0";
rgb-order = <&dpi_node_generic>, "rgb_order";
};
};
22 changes: 22 additions & 0 deletions drivers/gpu/drm/vc4/vc4_dpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ struct vc4_dpi {
struct clk *core_clock;

struct debugfs_regset32 regset;

int rgb_order_override;
};

#define to_vc4_dpi(_encoder) \
Expand Down Expand Up @@ -205,6 +207,11 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder)
}
}

if (dpi->rgb_order_override >= 0) {
dpi_c &= ~DPI_ORDER_MASK;
dpi_c |= VC4_SET_FIELD(dpi->rgb_order_override, DPI_ORDER);
}

if (connector->display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE)
dpi_c |= DPI_PIXEL_CLK_INVERT;

Expand Down Expand Up @@ -313,6 +320,7 @@ static int vc4_dpi_bind(struct device *dev, struct device *master, void *data)
{
struct platform_device *pdev = to_platform_device(dev);
struct drm_device *drm = dev_get_drvdata(master);
const char *rgb_order = NULL;
struct vc4_dpi *dpi;
int ret;

Expand Down Expand Up @@ -361,6 +369,20 @@ static int vc4_dpi_bind(struct device *dev, struct device *master, void *data)
if (ret)
return ret;

dpi->rgb_order_override = -1;
if (!of_property_read_string(dev->of_node, "rgb_order", &rgb_order)) {
if (!strcmp(rgb_order, "rgb"))
dpi->rgb_order_override = DPI_ORDER_RGB;
else if (!strcmp(rgb_order, "bgr"))
dpi->rgb_order_override = DPI_ORDER_BGR;
else if (!strcmp(rgb_order, "grb"))
dpi->rgb_order_override = DPI_ORDER_GRB;
else if (!strcmp(rgb_order, "brg"))
dpi->rgb_order_override = DPI_ORDER_BRG;
else
DRM_ERROR("Invalid dpi order %s - ignored\n", rgb_order);
}

ret = drmm_encoder_init(drm, &dpi->encoder.base,
&vc4_dpi_encoder_funcs,
DRM_MODE_ENCODER_DPI,
Expand Down