[Intel-gfx] [PATCH] TV: Add Luma filter table for composite TV

Zhenyu Wang zhenyu.z.wang at intel.com
Wed Oct 29 16:02:05 CET 2008


Grab luma filter table from video bios for composite TV, which is
different from normal filter table.

Note that this hasn't been tested, as I don't have machines with
composite TV output.
---
 src/i810_reg.h |    1 +
 src/i830_tv.c  |  138 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 135 insertions(+), 4 deletions(-)

diff --git a/src/i810_reg.h b/src/i810_reg.h
index e9c03e5..7967791 100644
--- a/src/i810_reg.h
+++ b/src/i810_reg.h
@@ -1551,6 +1551,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 # define TV_ENC_OUTPUT_COMPONENT	(2 << 28)
 /** Outputs Composite and SVideo (DAC A/B/C) */
 # define TV_ENC_OUTPUT_SVIDEO_COMPOSITE	(3 << 28)
+# define TV_ENC_OUTPUT_MASK		(3 << 28)
 # define TV_TRILEVEL_SYNC		(1 << 21)
 /** Enables slow sync generation (945GM only) */
 # define TV_SLOW_SYNC			(1 << 20)
diff --git a/src/i830_tv.c b/src/i830_tv.c
index 5c6a031..038ad2b 100644
--- a/src/i830_tv.c
+++ b/src/i830_tv.c
@@ -104,6 +104,7 @@ typedef struct {
 } color_conversion_t;
 
 static const uint32_t filter_table[] = {
+    /* H_LUMA_CHROMA_ALL: for LUMA */
     0xB1403000, 0x2E203500, 0x35002E20, 0x3000B140,
     0x35A0B160, 0x2DC02E80, 0xB1403480, 0xB1603000,
     0x2EA03640, 0x34002D80, 0x3000B120, 0x36E0B160,
@@ -119,6 +120,7 @@ static const uint32_t filter_table[] = {
     0xB0803000, 0xB100B040, 0x18483EC0, 0xB0402900,
     0xB040B060, 0x3F80B0C0, 0x28801858, 0xB060B080,
     0xB0A0B060, 0x18602820, 0xB0A02820, 0x0000B060,
+    /* H_LUMA_CHROMA_ALL: for CHROMA */
     0xB1403000, 0x2E203500, 0x35002E20, 0x3000B140,
     0x35A0B160, 0x2DC02E80, 0xB1403480, 0xB1603000,
     0x2EA03640, 0x34002D80, 0x3000B120, 0x36E0B160,
@@ -134,6 +136,7 @@ static const uint32_t filter_table[] = {
     0xB0803000, 0xB100B040, 0x18483EC0, 0xB0402900,
     0xB040B060, 0x3F80B0C0, 0x28801858, 0xB060B080,
     0xB0A0B060, 0x18602820, 0xB0A02820, 0x0000B060,
+    /* V_LUMA_CHROMA: for LUMA */
     0x36403000, 0x2D002CC0, 0x30003640, 0x2D0036C0,
     0x35C02CC0, 0x37403000, 0x2C802D40, 0x30003540,
     0x2D8037C0, 0x34C02C40, 0x38403000, 0x2BC02E00,
@@ -144,8 +147,9 @@ static const uint32_t filter_table[] = {
     0x2EC03C80, 0x320029C0, 0x3D403080, 0x29402F00,
     0x308031C0, 0x2F203DC0, 0x31802900, 0x3E8030C0,
     0x28802F40, 0x30C03140, 0x2F203F40, 0x31402840,
-    0x28003100, 0x28002F00, 0x00003100, 0x36403000,
-    0x2D002CC0, 0x30003640, 0x2D0036C0,
+    0x28003100, 0x28002F00, 0x00003100,
+    /* V_LUMA_CHROMA: for CHROMA*/
+    0x36403000, 0x2D002CC0, 0x30003640, 0x2D0036C0,
     0x35C02CC0, 0x37403000, 0x2C802D40, 0x30003540,
     0x2D8037C0, 0x34C02C40, 0x38403000, 0x2BC02E00,
     0x30003440, 0x2E2038C0, 0x34002B80, 0x39803000,
@@ -158,8 +162,61 @@ static const uint32_t filter_table[] = {
     0x28003100, 0x28002F00, 0x00003100,
 };
 
+static const uint32_t composite_ntsc_luma_filter_table[] = {
+    /* H_LUMA_CVBS_NTSC : Composite NTSC */
+    0x32C03000, 0x28403CC0, 0x3CC02840, 0x300032C0,
+    0x3D003300, 0x28402840, 0x32803C80, 0x33403000,
+    0x28203D60, 0x3C402840, 0x30003260, 0x3DA03380,
+    0x28402830, 0x32203BE0, 0x33E03000, 0x28303DC0,
+    0x3BA02840, 0x300031E0, 0x3E003420, 0x28402820,
+    0x31C03B60, 0x34603000, 0x28303E40, 0x3B002840,
+    0x30003180, 0x3E8034A0, 0x28402830, 0x31603AA0,
+    0x35003000, 0x28403EA0, 0x3A602820, 0x30203140,
+    0x3EE03540, 0x28202830, 0x31203A00, 0x35A03020,
+    0x28303F00, 0x39A02820, 0x30203100, 0x3F403600,
+    0x28202810, 0x30E03960, 0x36403020, 0x28203F60,
+    0x39002820, 0x304030C0, 0x3F8036A0, 0x28002830,
+    0x30A038A0, 0x37003040, 0x28203FA0, 0x38602800,
+    0x30403080, 0x3FC03740, 0x28002820, 0x30803800,
+    0x37A03060, 0x28203FE0, 0x37A03FE0, 0x00003060,
+};
+
+static const uint32_t composite_pal_luma_filter_table[] = {
+    /* H_LUMA_CVBS_PAL : Composite PAL */
+    0x0B0203000, 0x02A603B60, 0x03B602A60, 0x03000B020,
+    0x03BE03000, 0x02A602A60, 0x0B0403AE0, 0x030203000,
+    0x02A703C60, 0x03A802A40, 0x03000B060, 0x03CE03060,
+    0x02A402A50, 0x0B0603A00, 0x030803000, 0x02A803D40,
+    0x039802A20, 0x0B020B080, 0x03DC030C0, 0x02A202A70,
+    0x0B0803900, 0x030E0B020, 0x02AA03E20, 0x038802A00,
+    0x0B020B0A0, 0x03EA03120, 0x029E02AA0, 0x0B0A03800,
+    0x03160B020, 0x02A803F00, 0x037A029E0, 0x0B040B0A0,
+    0x03F6031A0, 0x029C02AA0, 0x0B0A03720, 0x03200B040,
+    0x02AA03FC0, 0x036A029A0, 0x0B040B0A0, 0x028203240,
+    0x029802AA0, 0x0B0A03620, 0x032A0B060, 0x02A902840,
+    0x035C02980, 0x0B060B0A0, 0x028603300, 0x029602AA0,
+    0x0B0A03540, 0x03340B060, 0x02A9028A0, 0x034E02940,
+    0x0B080B0A0, 0x028C033A0, 0x029002AB0, 0x0B0803480,
+    0x03400B080, 0x02AC028E0, 0x0340028E0, 0x00000B080,
+};
+
+typedef enum {
+    TV_NTSC_M,
+    TV_NTSC_J,
+    TV_NTSC_443,
+    TV_PAL_M,
+    TV_PAL_N,
+    TV_PAL,
+    TV_480i,
+    TV_480p,
+    TV_576i,
+    TV_576p,
+    TV_HDTV,
+} tv_mode_type_t;
+
 typedef struct {
     char *name;
+    tv_mode_type_t type;
     int	clock;
     double refresh;
     uint32_t oversample;
@@ -225,6 +282,7 @@ typedef struct {
 const static tv_mode_t tv_modes[] = {
     {
 	.name		= "NTSC-M",
+	.type		= TV_NTSC_M,
 	.clock		= 108000,
 	.refresh	= 29.97,
 	.oversample	= TV_OVERSAMPLE_8X,
@@ -276,6 +334,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name		= "NTSC-443",
+	.type		= TV_NTSC_443,
 	.clock		= 108000,
 	.refresh	= 29.97,
 	.oversample	= TV_OVERSAMPLE_8X,
@@ -326,6 +385,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name		= "NTSC-J",
+	.type		= TV_NTSC_J,
 	.clock		= 108000,
 	.refresh	= 29.97,
 	.oversample	= TV_OVERSAMPLE_8X,
@@ -377,6 +437,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name		= "PAL-M",
+	.type		= TV_PAL_M,
 	.clock		= 108000,
 	.refresh	= 29.97,
 	.oversample	= TV_OVERSAMPLE_8X,
@@ -429,6 +490,7 @@ const static tv_mode_t tv_modes[] = {
     {
 	/* 625 Lines, 50 Fields, 15.625KHz line, Sub-Carrier 4.434MHz */
 	.name	    = "PAL-N",
+	.type		= TV_PAL_N,
 	.clock		= 108000,
 	.refresh	= 25.0,
 	.oversample	= TV_OVERSAMPLE_8X,
@@ -482,6 +544,7 @@ const static tv_mode_t tv_modes[] = {
     {
 	/* 625 Lines, 50 Fields, 15.625KHz line, Sub-Carrier 4.434MHz */
 	.name	    = "PAL",
+	.type		= TV_PAL,
 	.clock		= 108000,
 	.refresh	= 25.0,
 	.oversample	= TV_OVERSAMPLE_8X,
@@ -532,6 +595,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name       = "480p at 59.94Hz",
+	.type		= TV_480p,
 	.clock		= 107520,
 	.refresh	= 59.94,
 	.oversample     = TV_OVERSAMPLE_4X,
@@ -556,6 +620,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name       = "480p at 60Hz",
+	.type		= TV_480p,
 	.clock		= 107520,
 	.refresh	= 60.0,
 	.oversample     = TV_OVERSAMPLE_4X,
@@ -580,6 +645,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name       = "576p",
+	.type		= TV_576p,
 	.clock		= 107520,
 	.refresh	= 50.0,
 	.oversample     = TV_OVERSAMPLE_4X,
@@ -604,6 +670,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name       = "720p at 60Hz",
+	.type		= TV_HDTV,
 	.clock		= 148800,
 	.refresh	= 60.0,
 	.oversample     = TV_OVERSAMPLE_2X,
@@ -628,6 +695,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name       = "720p at 59.94Hz",
+	.type		= TV_HDTV,
 	.clock		= 148800,
 	.refresh	= 59.94,
 	.oversample     = TV_OVERSAMPLE_2X,
@@ -652,6 +720,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name       = "720p at 50Hz",
+	.type		= TV_HDTV,
 	.clock		= 148800,
 	.refresh	= 50.0,
 	.oversample     = TV_OVERSAMPLE_2X,
@@ -677,6 +746,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name       = "1080i at 50Hz",
+	.type		= TV_HDTV,
 	.clock		= 148800,
 	.refresh	= 25.0,
 	.oversample     = TV_OVERSAMPLE_2X,
@@ -702,6 +772,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name       = "1080i at 60Hz",
+	.type		= TV_HDTV,
 	.clock		= 148800,
 	.refresh	= 30.0,
 	.oversample     = TV_OVERSAMPLE_2X,
@@ -727,6 +798,7 @@ const static tv_mode_t tv_modes[] = {
     },
     {
 	.name       = "1080i at 59.94Hz",
+	.type		= TV_HDTV,
 	.clock		= 148800,
 	.refresh	= 29.97,
 	.oversample     = TV_OVERSAMPLE_2X,
@@ -1019,6 +1091,54 @@ i830_float_to_luma (float f)
     return ret;
 }
 
+static Bool
+i830_tv_is_ntsc(const tv_mode_t *tv_mode)
+{
+    if (tv_mode->type >= TV_NTSC_M && tv_mode->type <= TV_NTSC_443)
+	return TRUE;
+    else
+	return FALSE;
+}
+
+static Bool
+i830_tv_is_pal(const tv_mode_t *tv_mode)
+{
+    if (tv_mode->type >= TV_PAL_M && tv_mode->type <= TV_PAL)
+	return TRUE;
+    else
+	return FALSE;
+}
+
+static Bool
+i830_tv_is_composite(xf86OutputPtr output)
+{
+    ScrnInfoPtr		    pScrn = output->scrn;
+    I830Ptr		    pI830 = I830PTR(pScrn);
+    uint32_t		    tv_ctl = INREG(TV_CTL);
+
+    return ((tv_ctl & TV_ENC_OUTPUT_MASK) == TV_ENC_OUTPUT_COMPOSITE);
+}
+
+static Bool
+i830_tv_is_svideo(xf86OutputPtr output)
+{
+    ScrnInfoPtr		    pScrn = output->scrn;
+    I830Ptr		    pI830 = I830PTR(pScrn);
+    uint32_t		    tv_ctl = INREG(TV_CTL);
+
+    return ((tv_ctl & TV_ENC_OUTPUT_MASK) == TV_ENC_OUTPUT_SVIDEO);
+}
+
+static Bool
+i830_tv_is_component(xf86OutputPtr output)
+{
+    ScrnInfoPtr		    pScrn = output->scrn;
+    I830Ptr		    pI830 = I830PTR(pScrn);
+    uint32_t		    tv_ctl = INREG(TV_CTL);
+
+    return ((tv_ctl & TV_ENC_OUTPUT_MASK) == TV_ENC_OUTPUT_COMPONENT);
+}
+
 static void
 i830_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode,
 		DisplayModePtr adjusted_mode)
@@ -1231,8 +1351,18 @@ i830_tv_mode_set(xf86OutputPtr output, DisplayModePtr mode,
     }
 
     j = 0;
-    for (i = 0; i < 60; i++)
-	OUTREG(TV_H_LUMA_0 + (i<<2), tv_mode->filter_table[j++]);
+    if (i830_tv_is_composite(output)) {
+	if (i830_tv_is_ntsc(tv_mode)) {
+	    for (i = 0; i < 60; i++)
+		OUTREG(TV_H_LUMA_0 + (i<<2), composite_ntsc_luma_filter_table[j++]);
+	} else if (i830_tv_is_pal(tv_mode)) {
+	    for (i = 0; i < 60; i++)
+		OUTREG(TV_H_LUMA_0 + (i<<2), composite_pal_luma_filter_table[j++]);
+	}
+    } else {
+	for (i = 0; i < 60; i++)
+	    OUTREG(TV_H_LUMA_0 + (i<<2), tv_mode->filter_table[j++]);
+    }
     for (i = 0; i < 60; i++)
 	OUTREG(TV_H_CHROMA_0 + (i<<2), tv_mode->filter_table[j++]);
     for (i = 0; i < 43; i++)
-- 
1.5.6.5




More information about the Intel-gfx mailing list