From: Huang Jiachai Date: Thu, 8 Dec 2016 13:03:54 +0000 (+0800) Subject: drm/rockchip: add dither config for connected panel X-Git-Tag: firefly_0821_release~1114 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=80da81fea704a01560660468903b4ee8500a4946;p=firefly-linux-kernel-4.4.55.git drm/rockchip: add dither config for connected panel Change-Id: Ia57d2ab75718d0a7a8b386a7d50e2e23011baeb2 Signed-off-by: Huang Jiachai --- diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 99d78eeec036..252c27d21d0f 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -1036,6 +1036,7 @@ static const struct panel_desc lg_lp079qx1_sp0v = { .width = 129, .height = 171, }, + .bus_format = MEDIA_BUS_FMT_RGB666_1X18, }; static const struct drm_display_mode lg_lp097qx1_spa1_mode = { diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index f32b39a2b0c3..434f63499725 100644 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c @@ -169,6 +169,8 @@ rockchip_dp_drm_encoder_atomic_check(struct drm_encoder *encoder, struct drm_connector_state *conn_state) { struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc_state); + struct drm_connector *connector = conn_state->connector; + struct drm_display_info *info = &connector->display_info; /* * The hardware IC designed that VOP must output the RGB10 video @@ -179,6 +181,8 @@ rockchip_dp_drm_encoder_atomic_check(struct drm_encoder *encoder, */ s->output_mode = ROCKCHIP_OUT_MODE_AAAA; s->output_type = DRM_MODE_CONNECTOR_eDP; + if (info->num_bus_formats) + s->bus_format = info->bus_formats[0]; return 0; } diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index f261dd97e130..0539b6e40b23 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c @@ -973,6 +973,8 @@ dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder, { struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc_state); struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder); + struct drm_connector *connector = conn_state->connector; + struct drm_display_info *info = &connector->display_info; switch (dsi->format) { case MIPI_DSI_FMT_RGB888: @@ -990,6 +992,8 @@ dw_mipi_dsi_encoder_atomic_check(struct drm_encoder *encoder, } s->output_type = DRM_MODE_CONNECTOR_DSI; + if (info->num_bus_formats) + s->bus_format = info->bus_formats[0]; return 0; } diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c index 52ac77e0130d..02e424b6f3ad 100644 --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c @@ -394,6 +394,7 @@ dw_hdmi_rockchip_encoder_atomic_check(struct drm_encoder *encoder, s->output_mode = ROCKCHIP_OUT_MODE_AAAA; s->output_type = DRM_MODE_CONNECTOR_HDMIA; + s->bus_format = MEDIA_BUS_FMT_RGB888_1X24; return 0; } diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c index f9d1fbb0cbc3..97eada481777 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c @@ -589,6 +589,7 @@ inno_hdmi_encoder_atomic_check(struct drm_encoder *encoder, s->output_mode = ROCKCHIP_OUT_MODE_P888; s->output_type = DRM_MODE_CONNECTOR_HDMIA; + s->bus_format = MEDIA_BUS_FMT_RGB888_1X24; return 0; } diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index 72db38bfe84c..77860ef22364 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -73,6 +73,7 @@ struct rockchip_crtc_state { int dsp_layer_sel; int output_type; int output_mode; + int bus_format; }; #define to_rockchip_crtc_state(s) \ diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index d4bf02066b11..b06fb556de54 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1412,6 +1412,23 @@ static void vop_crtc_enable(struct drm_crtc *crtc) s->output_mode = ROCKCHIP_OUT_MODE_P888; VOP_CTRL_SET(vop, out_mode, s->output_mode); + switch (s->bus_format) { + case MEDIA_BUS_FMT_RGB565_1X16: + val = DITHER_DOWN_EN(1) | DITHER_DOWN_MODE(RGB888_TO_RGB565) | + PRE_DITHER_DOWN_EN(1); + break; + case MEDIA_BUS_FMT_RGB666_1X18: + case MEDIA_BUS_FMT_RGB666_1X24_CPADHI: + val = DITHER_DOWN_EN(1) | DITHER_DOWN_MODE(RGB888_TO_RGB666) | + PRE_DITHER_DOWN_EN(1); + break; + case MEDIA_BUS_FMT_RGB888_1X24: + default: + val = DITHER_DOWN_EN(0) | PRE_DITHER_DOWN_EN(0); + break; + } + val |= DITHER_DOWN_MODE_SEL(DITHER_DOWN_ALLEGRO); + VOP_CTRL_SET(vop, dither_down, val); VOP_CTRL_SET(vop, htotal_pw, (htotal << 16) | hsync_len); val = hact_st << 16; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h index 5d2d3ced7689..b15288b1720e 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.h @@ -378,6 +378,20 @@ enum scale_down_mode { SCALE_DOWN_AVG = 0x1 }; +enum dither_down_mode { + RGB888_TO_RGB565 = 0x0, + RGB888_TO_RGB666 = 0x1 +}; + +enum dither_down_mode_sel { + DITHER_DOWN_ALLEGRO = 0x0, + DITHER_DOWN_FRC = 0x1 +}; + +#define PRE_DITHER_DOWN_EN(x) ((x) << 0) +#define DITHER_DOWN_EN(x) ((x) << 1) +#define DITHER_DOWN_MODE(x) ((x) << 2) +#define DITHER_DOWN_MODE_SEL(x) ((x) << 3) #define FRAC_16_16(mult, div) (((mult) << 16) / (div)) #define SCL_FT_DEFAULT_FIXPOINT_SHIFT 12 #define SCL_MAX_VSKIPLINES 4 diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c index 2649a044f2bb..e0eb524d0205 100644 --- a/drivers/gpu/drm/rockchip/rockchip_lvds.c +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c @@ -376,9 +376,13 @@ rockchip_lvds_encoder_atomic_check(struct drm_encoder *encoder, struct drm_connector_state *conn_state) { struct rockchip_crtc_state *s = to_rockchip_crtc_state(crtc_state); + struct drm_connector *connector = conn_state->connector; + struct drm_display_info *info = &connector->display_info; s->output_mode = ROCKCHIP_OUT_MODE_P888; s->output_type = DRM_MODE_CONNECTOR_LVDS; + if (info->num_bus_formats) + s->bus_format = info->bus_formats[0]; return 0; }