Add get_output_bus_format in dw_hdmi_plat_data to get hdmi output bus format. The output bus format is determined by color format and depth, which can be set by rockchip hdmi properties. Signed-off-by: Algea Cao <algea.cao@xxxxxxxxxxxxxx> --- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 47 +++++++++++++++++++++ include/drm/bridge/dw_hdmi.h | 1 + 2 files changed, 48 insertions(+) diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c index 8f22d9a566db..a602d25639a7 100644 --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c @@ -100,6 +100,7 @@ struct rockchip_hdmi { unsigned int colordepth; enum drm_hdmi_output_type hdmi_output; + unsigned long output_bus_format; }; #define to_rockchip_hdmi(x) container_of(x, struct rockchip_hdmi, x) @@ -498,6 +499,50 @@ static const struct dw_hdmi_property_ops dw_hdmi_rockchip_property_ops = { .get_property = dw_hdmi_rockchip_get_property, }; +static void +dw_hdmi_rockchip_output_bus_format_select(struct rockchip_hdmi *hdmi) +{ + unsigned long bus_format; + + if (hdmi->hdmi_output == DRM_HDMI_OUTPUT_YCBCR420) { + if (hdmi->colordepth > 8) + bus_format = MEDIA_BUS_FMT_UYYVYY10_0_5X30; + else + bus_format = MEDIA_BUS_FMT_UYYVYY8_0_5X24; + } else if (hdmi->hdmi_output == DRM_HDMI_OUTPUT_YCBCR422) { + if (hdmi->colordepth == 12) + bus_format = MEDIA_BUS_FMT_UYVY12_1X24; + else if (hdmi->colordepth == 10) + bus_format = MEDIA_BUS_FMT_UYVY10_1X20; + else + bus_format = MEDIA_BUS_FMT_UYVY8_1X16; + } else { + if (hdmi->colordepth > 8) { + if (hdmi->hdmi_output != DRM_HDMI_OUTPUT_DEFAULT_RGB) + bus_format = MEDIA_BUS_FMT_YUV10_1X30; + else + bus_format = MEDIA_BUS_FMT_RGB101010_1X30; + } else { + if (hdmi->hdmi_output != DRM_HDMI_OUTPUT_DEFAULT_RGB) + bus_format = MEDIA_BUS_FMT_YUV8_1X24; + else + bus_format = MEDIA_BUS_FMT_RGB888_1X24; + } + } + + hdmi->output_bus_format = bus_format; +} + +static unsigned long +dw_hdmi_rockchip_get_output_bus_format(void *data) +{ + struct rockchip_hdmi *hdmi = (struct rockchip_hdmi *)data; + + dw_hdmi_rockchip_output_bus_format_select(hdmi); + + return hdmi->output_bus_format; +} + static void dw_hdmi_rk3228_setup_hpd(struct dw_hdmi *dw_hdmi, void *data) { struct rockchip_hdmi *hdmi = (struct rockchip_hdmi *)data; @@ -685,6 +730,8 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, plat_data->property_ops = &dw_hdmi_rockchip_property_ops; + plat_data->get_output_bus_format = + dw_hdmi_rockchip_get_output_bus_format; encoder = &hdmi->encoder; encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node); diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index dc561ebe7a9b..13495f810328 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -175,6 +175,7 @@ struct dw_hdmi_plat_data { const struct dw_hdmi_phy_config *phy_config; int (*configure_phy)(struct dw_hdmi *hdmi, void *data, unsigned long mpixelclock); + unsigned long (*get_output_bus_format)(void *data); }; struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel