aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Armstrong <narmstrong@baylibre.com>2017-04-04 08:31:57 -0400
committerNeil Armstrong <narmstrong@baylibre.com>2017-04-04 11:48:21 -0400
commitdef23aa7e9821a3dfe3fb7b139dd0229a89fdeb0 (patch)
tree4ba0c078de373096aaeaf2e4cb6cda1a01f82a22
parenta23d6265f033501529932db2d6b3f4bc138552ab (diff)
drm: bridge: dw-hdmi: Switch to V4L bus format and encodings
Switch code to use the newly introduced V4L bus formats IDs instead of custom defines. Also use the V4L encoding defines. Some display pipelines can only provide non-RBG input pixels to the HDMI TX Controller, this patch takes the pixel format from the plat_data if provided. Reviewed-by: Jose Abreu <joabreu@synopsys.com> Reviewed-by: Archit Taneja <architt@codeaurora.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
-rw-r--r--drivers/gpu/drm/bridge/synopsys/dw-hdmi.c326
-rw-r--r--include/drm/bridge/dw_hdmi.h63
2 files changed, 294 insertions, 95 deletions
diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index ff1fae3a31a4..16d5fff3e697 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -30,18 +30,15 @@
30#include <drm/drm_encoder_slave.h> 30#include <drm/drm_encoder_slave.h>
31#include <drm/bridge/dw_hdmi.h> 31#include <drm/bridge/dw_hdmi.h>
32 32
33#include <uapi/linux/media-bus-format.h>
34#include <uapi/linux/videodev2.h>
35
33#include "dw-hdmi.h" 36#include "dw-hdmi.h"
34#include "dw-hdmi-audio.h" 37#include "dw-hdmi-audio.h"
35 38
36#define DDC_SEGMENT_ADDR 0x30 39#define DDC_SEGMENT_ADDR 0x30
37#define HDMI_EDID_LEN 512 40#define HDMI_EDID_LEN 512
38 41
39#define RGB 0
40#define YCBCR444 1
41#define YCBCR422_16BITS 2
42#define YCBCR422_8BITS 3
43#define XVYCC444 4
44
45enum hdmi_datamap { 42enum hdmi_datamap {
46 RGB444_8B = 0x01, 43 RGB444_8B = 0x01,
47 RGB444_10B = 0x03, 44 RGB444_10B = 0x03,
@@ -95,10 +92,10 @@ struct hdmi_vmode {
95}; 92};
96 93
97struct hdmi_data_info { 94struct hdmi_data_info {
98 unsigned int enc_in_format; 95 unsigned int enc_in_bus_format;
99 unsigned int enc_out_format; 96 unsigned int enc_out_bus_format;
100 unsigned int enc_color_depth; 97 unsigned int enc_in_encoding;
101 unsigned int colorimetry; 98 unsigned int enc_out_encoding;
102 unsigned int pix_repet_factor; 99 unsigned int pix_repet_factor;
103 unsigned int hdcp_enable; 100 unsigned int hdcp_enable;
104 struct hdmi_vmode video_mode; 101 struct hdmi_vmode video_mode;
@@ -567,6 +564,92 @@ void dw_hdmi_audio_disable(struct dw_hdmi *hdmi)
567} 564}
568EXPORT_SYMBOL_GPL(dw_hdmi_audio_disable); 565EXPORT_SYMBOL_GPL(dw_hdmi_audio_disable);
569 566
567static bool hdmi_bus_fmt_is_rgb(unsigned int bus_format)
568{
569 switch (bus_format) {
570 case MEDIA_BUS_FMT_RGB888_1X24:
571 case MEDIA_BUS_FMT_RGB101010_1X30:
572 case MEDIA_BUS_FMT_RGB121212_1X36:
573 case MEDIA_BUS_FMT_RGB161616_1X48:
574 return true;
575
576 default:
577 return false;
578 }
579}
580
581static bool hdmi_bus_fmt_is_yuv444(unsigned int bus_format)
582{
583 switch (bus_format) {
584 case MEDIA_BUS_FMT_YUV8_1X24:
585 case MEDIA_BUS_FMT_YUV10_1X30:
586 case MEDIA_BUS_FMT_YUV12_1X36:
587 case MEDIA_BUS_FMT_YUV16_1X48:
588 return true;
589
590 default:
591 return false;
592 }
593}
594
595static bool hdmi_bus_fmt_is_yuv422(unsigned int bus_format)
596{
597 switch (bus_format) {
598 case MEDIA_BUS_FMT_UYVY8_1X16:
599 case MEDIA_BUS_FMT_UYVY10_1X20:
600 case MEDIA_BUS_FMT_UYVY12_1X24:
601 return true;
602
603 default:
604 return false;
605 }
606}
607
608static bool hdmi_bus_fmt_is_yuv420(unsigned int bus_format)
609{
610 switch (bus_format) {
611 case MEDIA_BUS_FMT_UYYVYY8_0_5X24:
612 case MEDIA_BUS_FMT_UYYVYY10_0_5X30:
613 case MEDIA_BUS_FMT_UYYVYY12_0_5X36:
614 case MEDIA_BUS_FMT_UYYVYY16_0_5X48:
615 return true;
616
617 default:
618 return false;
619 }
620}
621
622static int hdmi_bus_fmt_color_depth(unsigned int bus_format)
623{
624 switch (bus_format) {
625 case MEDIA_BUS_FMT_RGB888_1X24:
626 case MEDIA_BUS_FMT_YUV8_1X24:
627 case MEDIA_BUS_FMT_UYVY8_1X16:
628 case MEDIA_BUS_FMT_UYYVYY8_0_5X24:
629 return 8;
630
631 case MEDIA_BUS_FMT_RGB101010_1X30:
632 case MEDIA_BUS_FMT_YUV10_1X30:
633 case MEDIA_BUS_FMT_UYVY10_1X20:
634 case MEDIA_BUS_FMT_UYYVYY10_0_5X30:
635 return 10;
636
637 case MEDIA_BUS_FMT_RGB121212_1X36:
638 case MEDIA_BUS_FMT_YUV12_1X36:
639 case MEDIA_BUS_FMT_UYVY12_1X24:
640 case MEDIA_BUS_FMT_UYYVYY12_0_5X36:
641 return 12;
642
643 case MEDIA_BUS_FMT_RGB161616_1X48:
644 case MEDIA_BUS_FMT_YUV16_1X48:
645 case MEDIA_BUS_FMT_UYYVYY16_0_5X48:
646 return 16;
647
648 default:
649 return 0;
650 }
651}
652
570/* 653/*
571 * this submodule is responsible for the video data synchronization. 654 * this submodule is responsible for the video data synchronization.
572 * for example, for RGB 4:4:4 input, the data map is defined as 655 * for example, for RGB 4:4:4 input, the data map is defined as
@@ -579,37 +662,49 @@ static void hdmi_video_sample(struct dw_hdmi *hdmi)
579 int color_format = 0; 662 int color_format = 0;
580 u8 val; 663 u8 val;
581 664
582 if (hdmi->hdmi_data.enc_in_format == RGB) { 665 switch (hdmi->hdmi_data.enc_in_bus_format) {
583 if (hdmi->hdmi_data.enc_color_depth == 8) 666 case MEDIA_BUS_FMT_RGB888_1X24:
584 color_format = 0x01; 667 color_format = 0x01;
585 else if (hdmi->hdmi_data.enc_color_depth == 10) 668 break;
586 color_format = 0x03; 669 case MEDIA_BUS_FMT_RGB101010_1X30:
587 else if (hdmi->hdmi_data.enc_color_depth == 12) 670 color_format = 0x03;
588 color_format = 0x05; 671 break;
589 else if (hdmi->hdmi_data.enc_color_depth == 16) 672 case MEDIA_BUS_FMT_RGB121212_1X36:
590 color_format = 0x07; 673 color_format = 0x05;
591 else 674 break;
592 return; 675 case MEDIA_BUS_FMT_RGB161616_1X48:
593 } else if (hdmi->hdmi_data.enc_in_format == YCBCR444) { 676 color_format = 0x07;
594 if (hdmi->hdmi_data.enc_color_depth == 8) 677 break;
595 color_format = 0x09; 678
596 else if (hdmi->hdmi_data.enc_color_depth == 10) 679 case MEDIA_BUS_FMT_YUV8_1X24:
597 color_format = 0x0B; 680 case MEDIA_BUS_FMT_UYYVYY8_0_5X24:
598 else if (hdmi->hdmi_data.enc_color_depth == 12) 681 color_format = 0x09;
599 color_format = 0x0D; 682 break;
600 else if (hdmi->hdmi_data.enc_color_depth == 16) 683 case MEDIA_BUS_FMT_YUV10_1X30:
601 color_format = 0x0F; 684 case MEDIA_BUS_FMT_UYYVYY10_0_5X30:
602 else 685 color_format = 0x0B;
603 return; 686 break;
604 } else if (hdmi->hdmi_data.enc_in_format == YCBCR422_8BITS) { 687 case MEDIA_BUS_FMT_YUV12_1X36:
605 if (hdmi->hdmi_data.enc_color_depth == 8) 688 case MEDIA_BUS_FMT_UYYVYY12_0_5X36:
606 color_format = 0x16; 689 color_format = 0x0D;
607 else if (hdmi->hdmi_data.enc_color_depth == 10) 690 break;
608 color_format = 0x14; 691 case MEDIA_BUS_FMT_YUV16_1X48:
609 else if (hdmi->hdmi_data.enc_color_depth == 12) 692 case MEDIA_BUS_FMT_UYYVYY16_0_5X48:
610 color_format = 0x12; 693 color_format = 0x0F;
611 else 694 break;
612 return; 695
696 case MEDIA_BUS_FMT_UYVY8_1X16:
697 color_format = 0x16;
698 break;
699 case MEDIA_BUS_FMT_UYVY10_1X20:
700 color_format = 0x14;
701 break;
702 case MEDIA_BUS_FMT_UYVY12_1X24:
703 color_format = 0x12;
704 break;
705
706 default:
707 return;
613 } 708 }
614 709
615 val = HDMI_TX_INVID0_INTERNAL_DE_GENERATOR_DISABLE | 710 val = HDMI_TX_INVID0_INTERNAL_DE_GENERATOR_DISABLE |
@@ -632,26 +727,30 @@ static void hdmi_video_sample(struct dw_hdmi *hdmi)
632 727
633static int is_color_space_conversion(struct dw_hdmi *hdmi) 728static int is_color_space_conversion(struct dw_hdmi *hdmi)
634{ 729{
635 return hdmi->hdmi_data.enc_in_format != hdmi->hdmi_data.enc_out_format; 730 return hdmi->hdmi_data.enc_in_bus_format != hdmi->hdmi_data.enc_out_bus_format;
636} 731}
637 732
638static int is_color_space_decimation(struct dw_hdmi *hdmi) 733static int is_color_space_decimation(struct dw_hdmi *hdmi)
639{ 734{
640 if (hdmi->hdmi_data.enc_out_format != YCBCR422_8BITS) 735 if (!hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format))
641 return 0; 736 return 0;
642 if (hdmi->hdmi_data.enc_in_format == RGB || 737
643 hdmi->hdmi_data.enc_in_format == YCBCR444) 738 if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_in_bus_format) ||
739 hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_in_bus_format))
644 return 1; 740 return 1;
741
645 return 0; 742 return 0;
646} 743}
647 744
648static int is_color_space_interpolation(struct dw_hdmi *hdmi) 745static int is_color_space_interpolation(struct dw_hdmi *hdmi)
649{ 746{
650 if (hdmi->hdmi_data.enc_in_format != YCBCR422_8BITS) 747 if (!hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_in_bus_format))
651 return 0; 748 return 0;
652 if (hdmi->hdmi_data.enc_out_format == RGB || 749
653 hdmi->hdmi_data.enc_out_format == YCBCR444) 750 if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format) ||
751 hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format))
654 return 1; 752 return 1;
753
655 return 0; 754 return 0;
656} 755}
657 756
@@ -662,15 +761,16 @@ static void dw_hdmi_update_csc_coeffs(struct dw_hdmi *hdmi)
662 u32 csc_scale = 1; 761 u32 csc_scale = 1;
663 762
664 if (is_color_space_conversion(hdmi)) { 763 if (is_color_space_conversion(hdmi)) {
665 if (hdmi->hdmi_data.enc_out_format == RGB) { 764 if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format)) {
666 if (hdmi->hdmi_data.colorimetry == 765 if (hdmi->hdmi_data.enc_out_encoding ==
667 HDMI_COLORIMETRY_ITU_601) 766 V4L2_YCBCR_ENC_601)
668 csc_coeff = &csc_coeff_rgb_out_eitu601; 767 csc_coeff = &csc_coeff_rgb_out_eitu601;
669 else 768 else
670 csc_coeff = &csc_coeff_rgb_out_eitu709; 769 csc_coeff = &csc_coeff_rgb_out_eitu709;
671 } else if (hdmi->hdmi_data.enc_in_format == RGB) { 770 } else if (hdmi_bus_fmt_is_rgb(
672 if (hdmi->hdmi_data.colorimetry == 771 hdmi->hdmi_data.enc_in_bus_format)) {
673 HDMI_COLORIMETRY_ITU_601) 772 if (hdmi->hdmi_data.enc_out_encoding ==
773 V4L2_YCBCR_ENC_601)
674 csc_coeff = &csc_coeff_rgb_in_eitu601; 774 csc_coeff = &csc_coeff_rgb_in_eitu601;
675 else 775 else
676 csc_coeff = &csc_coeff_rgb_in_eitu709; 776 csc_coeff = &csc_coeff_rgb_in_eitu709;
@@ -708,16 +808,23 @@ static void hdmi_video_csc(struct dw_hdmi *hdmi)
708 else if (is_color_space_decimation(hdmi)) 808 else if (is_color_space_decimation(hdmi))
709 decimation = HDMI_CSC_CFG_DECMODE_CHROMA_INT_FORMULA3; 809 decimation = HDMI_CSC_CFG_DECMODE_CHROMA_INT_FORMULA3;
710 810
711 if (hdmi->hdmi_data.enc_color_depth == 8) 811 switch (hdmi_bus_fmt_color_depth(hdmi->hdmi_data.enc_out_bus_format)) {
812 case 8:
712 color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_24BPP; 813 color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_24BPP;
713 else if (hdmi->hdmi_data.enc_color_depth == 10) 814 break;
815 case 10:
714 color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_30BPP; 816 color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_30BPP;
715 else if (hdmi->hdmi_data.enc_color_depth == 12) 817 break;
818 case 12:
716 color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_36BPP; 819 color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_36BPP;
717 else if (hdmi->hdmi_data.enc_color_depth == 16) 820 break;
821 case 16:
718 color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_48BPP; 822 color_depth = HDMI_CSC_SCALE_CSC_COLORDE_PTH_48BPP;
719 else 823 break;
824
825 default:
720 return; 826 return;
827 }
721 828
722 /* Configure the CSC registers */ 829 /* Configure the CSC registers */
723 hdmi_writeb(hdmi, interpolation | decimation, HDMI_CSC_CFG); 830 hdmi_writeb(hdmi, interpolation | decimation, HDMI_CSC_CFG);
@@ -740,32 +847,43 @@ static void hdmi_video_packetize(struct dw_hdmi *hdmi)
740 struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; 847 struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data;
741 u8 val, vp_conf; 848 u8 val, vp_conf;
742 849
743 if (hdmi_data->enc_out_format == RGB || 850 if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format) ||
744 hdmi_data->enc_out_format == YCBCR444) { 851 hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format)) {
745 if (!hdmi_data->enc_color_depth) { 852 switch (hdmi_bus_fmt_color_depth(
746 output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; 853 hdmi->hdmi_data.enc_out_bus_format)) {
747 } else if (hdmi_data->enc_color_depth == 8) { 854 case 8:
748 color_depth = 4; 855 color_depth = 4;
749 output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS; 856 output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS;
750 } else if (hdmi_data->enc_color_depth == 10) { 857 break;
858 case 10:
751 color_depth = 5; 859 color_depth = 5;
752 } else if (hdmi_data->enc_color_depth == 12) { 860 break;
861 case 12:
753 color_depth = 6; 862 color_depth = 6;
754 } else if (hdmi_data->enc_color_depth == 16) { 863 break;
864 case 16:
755 color_depth = 7; 865 color_depth = 7;
756 } else { 866 break;
757 return; 867 default:
868 output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS;
758 } 869 }
759 } else if (hdmi_data->enc_out_format == YCBCR422_8BITS) { 870 } else if (hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) {
760 if (!hdmi_data->enc_color_depth || 871 switch (hdmi_bus_fmt_color_depth(
761 hdmi_data->enc_color_depth == 8) 872 hdmi->hdmi_data.enc_out_bus_format)) {
873 case 0:
874 case 8:
762 remap_size = HDMI_VP_REMAP_YCC422_16bit; 875 remap_size = HDMI_VP_REMAP_YCC422_16bit;
763 else if (hdmi_data->enc_color_depth == 10) 876 break;
877 case 10:
764 remap_size = HDMI_VP_REMAP_YCC422_20bit; 878 remap_size = HDMI_VP_REMAP_YCC422_20bit;
765 else if (hdmi_data->enc_color_depth == 12) 879 break;
880 case 12:
766 remap_size = HDMI_VP_REMAP_YCC422_24bit; 881 remap_size = HDMI_VP_REMAP_YCC422_24bit;
767 else 882 break;
883
884 default:
768 return; 885 return;
886 }
769 output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422; 887 output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422;
770 } else { 888 } else {
771 return; 889 return;
@@ -1148,28 +1266,35 @@ static void hdmi_config_AVI(struct dw_hdmi *hdmi, struct drm_display_mode *mode)
1148 /* Initialise info frame from DRM mode */ 1266 /* Initialise info frame from DRM mode */
1149 drm_hdmi_avi_infoframe_from_display_mode(&frame, mode); 1267 drm_hdmi_avi_infoframe_from_display_mode(&frame, mode);
1150 1268
1151 if (hdmi->hdmi_data.enc_out_format == YCBCR444) 1269 if (hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format))
1152 frame.colorspace = HDMI_COLORSPACE_YUV444; 1270 frame.colorspace = HDMI_COLORSPACE_YUV444;
1153 else if (hdmi->hdmi_data.enc_out_format == YCBCR422_8BITS) 1271 else if (hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format))
1154 frame.colorspace = HDMI_COLORSPACE_YUV422; 1272 frame.colorspace = HDMI_COLORSPACE_YUV422;
1155 else 1273 else
1156 frame.colorspace = HDMI_COLORSPACE_RGB; 1274 frame.colorspace = HDMI_COLORSPACE_RGB;
1157 1275
1158 /* Set up colorimetry */ 1276 /* Set up colorimetry */
1159 if (hdmi->hdmi_data.enc_out_format == XVYCC444) { 1277 switch (hdmi->hdmi_data.enc_out_encoding) {
1160 frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; 1278 case V4L2_YCBCR_ENC_601:
1161 if (hdmi->hdmi_data.colorimetry == HDMI_COLORIMETRY_ITU_601) 1279 if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV601)
1162 frame.extended_colorimetry = 1280 frame.colorimetry = HDMI_COLORIMETRY_EXTENDED;
1281 else
1282 frame.colorimetry = HDMI_COLORIMETRY_ITU_601;
1283 frame.extended_colorimetry =
1163 HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; 1284 HDMI_EXTENDED_COLORIMETRY_XV_YCC_601;
1164 else /*hdmi->hdmi_data.colorimetry == HDMI_COLORIMETRY_ITU_709*/ 1285 case V4L2_YCBCR_ENC_709:
1165 frame.extended_colorimetry = 1286 if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV709)
1287 frame.colorimetry = HDMI_COLORIMETRY_EXTENDED;
1288 else
1289 frame.colorimetry = HDMI_COLORIMETRY_ITU_709;
1290 frame.extended_colorimetry =
1166 HDMI_EXTENDED_COLORIMETRY_XV_YCC_709; 1291 HDMI_EXTENDED_COLORIMETRY_XV_YCC_709;
1167 } else if (hdmi->hdmi_data.enc_out_format != RGB) { 1292 break;
1168 frame.colorimetry = hdmi->hdmi_data.colorimetry; 1293 default: /* Carries no data */
1169 frame.extended_colorimetry = HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; 1294 frame.colorimetry = HDMI_COLORIMETRY_ITU_601;
1170 } else { /* Carries no data */ 1295 frame.extended_colorimetry =
1171 frame.colorimetry = HDMI_COLORIMETRY_NONE; 1296 HDMI_EXTENDED_COLORIMETRY_XV_YCC_601;
1172 frame.extended_colorimetry = HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; 1297 break;
1173 } 1298 }
1174 1299
1175 frame.scan_mode = HDMI_SCAN_MODE_NONE; 1300 frame.scan_mode = HDMI_SCAN_MODE_NONE;
@@ -1498,19 +1623,30 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode)
1498 (hdmi->vic == 21) || (hdmi->vic == 22) || 1623 (hdmi->vic == 21) || (hdmi->vic == 22) ||
1499 (hdmi->vic == 2) || (hdmi->vic == 3) || 1624 (hdmi->vic == 2) || (hdmi->vic == 3) ||
1500 (hdmi->vic == 17) || (hdmi->vic == 18)) 1625 (hdmi->vic == 17) || (hdmi->vic == 18))
1501 hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_601; 1626 hdmi->hdmi_data.enc_out_encoding = V4L2_YCBCR_ENC_601;
1502 else 1627 else
1503 hdmi->hdmi_data.colorimetry = HDMI_COLORIMETRY_ITU_709; 1628 hdmi->hdmi_data.enc_out_encoding = V4L2_YCBCR_ENC_709;
1504 1629
1505 hdmi->hdmi_data.video_mode.mpixelrepetitionoutput = 0; 1630 hdmi->hdmi_data.video_mode.mpixelrepetitionoutput = 0;
1506 hdmi->hdmi_data.video_mode.mpixelrepetitioninput = 0; 1631 hdmi->hdmi_data.video_mode.mpixelrepetitioninput = 0;
1507 1632
1508 /* TODO: Get input format from IPU (via FB driver interface) */ 1633 /* TOFIX: Get input format from plat data or fallback to RGB888 */
1509 hdmi->hdmi_data.enc_in_format = RGB; 1634 if (hdmi->plat_data->input_bus_format >= 0)
1635 hdmi->hdmi_data.enc_in_bus_format =
1636 hdmi->plat_data->input_bus_format;
1637 else
1638 hdmi->hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
1639
1640 /* TOFIX: Get input encoding from plat data or fallback to none */
1641 if (hdmi->plat_data->input_bus_encoding >= 0)
1642 hdmi->hdmi_data.enc_in_encoding =
1643 hdmi->plat_data->input_bus_encoding;
1644 else
1645 hdmi->hdmi_data.enc_in_encoding = V4L2_YCBCR_ENC_DEFAULT;
1510 1646
1511 hdmi->hdmi_data.enc_out_format = RGB; 1647 /* TOFIX: Default to RGB888 output format */
1648 hdmi->hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
1512 1649
1513 hdmi->hdmi_data.enc_color_depth = 8;
1514 hdmi->hdmi_data.pix_repet_factor = 0; 1650 hdmi->hdmi_data.pix_repet_factor = 0;
1515 hdmi->hdmi_data.hdcp_enable = 0; 1651 hdmi->hdmi_data.hdcp_enable = 0;
1516 hdmi->hdmi_data.video_mode.mdataenablepolarity = true; 1652 hdmi->hdmi_data.video_mode.mdataenablepolarity = true;
diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h
index bcceee8114a4..5d6b92c6c0bc 100644
--- a/include/drm/bridge/dw_hdmi.h
+++ b/include/drm/bridge/dw_hdmi.h
@@ -14,6 +14,67 @@
14 14
15struct dw_hdmi; 15struct dw_hdmi;
16 16
17/**
18 * DOC: Supported input formats and encodings
19 *
20 * Depending on the Hardware configuration of the Controller IP, it supports
21 * a subset of the following input formats and encodings on its internal
22 * 48bit bus.
23 *
24 * +----------------------+----------------------------------+------------------------------+
25 * + Format Name + Format Code + Encodings +
26 * +----------------------+----------------------------------+------------------------------+
27 * + RGB 4:4:4 8bit + ``MEDIA_BUS_FMT_RGB888_1X24`` + ``V4L2_YCBCR_ENC_DEFAULT`` +
28 * +----------------------+----------------------------------+------------------------------+
29 * + RGB 4:4:4 10bits + ``MEDIA_BUS_FMT_RGB101010_1X30`` + ``V4L2_YCBCR_ENC_DEFAULT`` +
30 * +----------------------+----------------------------------+------------------------------+
31 * + RGB 4:4:4 12bits + ``MEDIA_BUS_FMT_RGB121212_1X36`` + ``V4L2_YCBCR_ENC_DEFAULT`` +
32 * +----------------------+----------------------------------+------------------------------+
33 * + RGB 4:4:4 16bits + ``MEDIA_BUS_FMT_RGB161616_1X48`` + ``V4L2_YCBCR_ENC_DEFAULT`` +
34 * +----------------------+----------------------------------+------------------------------+
35 * + YCbCr 4:4:4 8bit + ``MEDIA_BUS_FMT_YUV8_1X24`` + ``V4L2_YCBCR_ENC_601`` +
36 * + + + or ``V4L2_YCBCR_ENC_709`` +
37 * + + + or ``V4L2_YCBCR_ENC_XV601`` +
38 * + + + or ``V4L2_YCBCR_ENC_XV709`` +
39 * +----------------------+----------------------------------+------------------------------+
40 * + YCbCr 4:4:4 10bits + ``MEDIA_BUS_FMT_YUV10_1X30`` + ``V4L2_YCBCR_ENC_601`` +
41 * + + + or ``V4L2_YCBCR_ENC_709`` +
42 * + + + or ``V4L2_YCBCR_ENC_XV601`` +
43 * + + + or ``V4L2_YCBCR_ENC_XV709`` +
44 * +----------------------+----------------------------------+------------------------------+
45 * + YCbCr 4:4:4 12bits + ``MEDIA_BUS_FMT_YUV12_1X36`` + ``V4L2_YCBCR_ENC_601`` +
46 * + + + or ``V4L2_YCBCR_ENC_709`` +
47 * + + + or ``V4L2_YCBCR_ENC_XV601`` +
48 * + + + or ``V4L2_YCBCR_ENC_XV709`` +
49 * +----------------------+----------------------------------+------------------------------+
50 * + YCbCr 4:4:4 16bits + ``MEDIA_BUS_FMT_YUV16_1X48`` + ``V4L2_YCBCR_ENC_601`` +
51 * + + + or ``V4L2_YCBCR_ENC_709`` +
52 * + + + or ``V4L2_YCBCR_ENC_XV601`` +
53 * + + + or ``V4L2_YCBCR_ENC_XV709`` +
54 * +----------------------+----------------------------------+------------------------------+
55 * + YCbCr 4:2:2 8bit + ``MEDIA_BUS_FMT_UYVY8_1X16`` + ``V4L2_YCBCR_ENC_601`` +
56 * + + + or ``V4L2_YCBCR_ENC_709`` +
57 * +----------------------+----------------------------------+------------------------------+
58 * + YCbCr 4:2:2 10bits + ``MEDIA_BUS_FMT_UYVY10_1X20`` + ``V4L2_YCBCR_ENC_601`` +
59 * + + + or ``V4L2_YCBCR_ENC_709`` +
60 * +----------------------+----------------------------------+------------------------------+
61 * + YCbCr 4:2:2 12bits + ``MEDIA_BUS_FMT_UYVY12_1X24`` + ``V4L2_YCBCR_ENC_601`` +
62 * + + + or ``V4L2_YCBCR_ENC_709`` +
63 * +----------------------+----------------------------------+------------------------------+
64 * + YCbCr 4:2:0 8bit + ``MEDIA_BUS_FMT_UYYVYY8_0_5X24`` + ``V4L2_YCBCR_ENC_601`` +
65 * + + + or ``V4L2_YCBCR_ENC_709`` +
66 * +----------------------+----------------------------------+------------------------------+
67 * + YCbCr 4:2:0 10bits + ``MEDIA_BUS_FMT_UYYVYY10_0_5X30``+ ``V4L2_YCBCR_ENC_601`` +
68 * + + + or ``V4L2_YCBCR_ENC_709`` +
69 * +----------------------+----------------------------------+------------------------------+
70 * + YCbCr 4:2:0 12bits + ``MEDIA_BUS_FMT_UYYVYY12_0_5X36``+ ``V4L2_YCBCR_ENC_601`` +
71 * + + + or ``V4L2_YCBCR_ENC_709`` +
72 * +----------------------+----------------------------------+------------------------------+
73 * + YCbCr 4:2:0 16bits + ``MEDIA_BUS_FMT_UYYVYY16_0_5X48``+ ``V4L2_YCBCR_ENC_601`` +
74 * + + + or ``V4L2_YCBCR_ENC_709`` +
75 * +----------------------+----------------------------------+------------------------------+
76 */
77
17enum { 78enum {
18 DW_HDMI_RES_8, 79 DW_HDMI_RES_8,
19 DW_HDMI_RES_10, 80 DW_HDMI_RES_10,
@@ -62,6 +123,8 @@ struct dw_hdmi_plat_data {
62 struct regmap *regm; 123 struct regmap *regm;
63 enum drm_mode_status (*mode_valid)(struct drm_connector *connector, 124 enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
64 struct drm_display_mode *mode); 125 struct drm_display_mode *mode);
126 unsigned long input_bus_format;
127 unsigned long input_bus_encoding;
65 128
66 /* Vendor PHY support */ 129 /* Vendor PHY support */
67 const struct dw_hdmi_phy_ops *phy_ops; 130 const struct dw_hdmi_phy_ops *phy_ops;