Skip to contentSkip to conversation

media: cx88 and usbtv: PAL-Nc fixes

PATCH New Jorge Maidana 1 participant 3 messages May 13, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover media: cx88 and usbtv: PAL-Nc fixes

This patch series fixes PAL-Nc support on cx88 and usbtv, it has been tested with PAL-Nc sources and an "MS1835 VGA to AV Converter" PCB label "MS1835_VGA2AV_DEMO_REV1.1" which has different output standards.

Jorge Maidana (2):
media: cx88: Fix PAL-Nc standard
media: usbtv: Add PAL-Nc standard

 drivers/media/pci/cx88/cx88-core.c    | 22 +++++++++++++++++-----
 drivers/media/usb/usbtv/usbtv-video.c |  5 ++++-
 drivers/media/usb/usbtv/usbtv.h       |  3 ++-
 3 files changed, 23 insertions(+), 7 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/2 media: cx88: Fix PAL-Nc standard

* Fix PAL-Nc horizontal parameters according to DScaler:
https://github.com/JohnAdders/DScaler/blob/f7d92b76678e/DScaler/TVFormats.cpp#L88-L94
* Add PAL-Nc TV audio support.
* Tested with CVBS and RF on a Pinnacle PCTV HD 800i.

---
 drivers/media/pci/cx88/cx88-core.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/media/pci/cx88/cx88-core.c +17 -5
index 89d4d5a3b..52be42f9a 100644
@@ -618,12 +618,24 @@ EXPORT_SYMBOL(cx88_reset);
 
 static inline unsigned int norm_swidth(v4l2_std_id norm)
 {
-	return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 754 : 922;
+	if (norm & (V4L2_STD_NTSC | V4L2_STD_PAL_M))
+		return 754;
+
+	if (norm & V4L2_STD_PAL_Nc)
+		return 745;
+
+	return 922;
 }
 
 static inline unsigned int norm_hdelay(v4l2_std_id norm)
 {
-	return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 135 : 186;
+	if (norm & (V4L2_STD_NTSC | V4L2_STD_PAL_M))
+		return 135;
+
+	if (norm & V4L2_STD_PAL_Nc)
+		return 149;
+
+	return 186;
 }
 
 static inline unsigned int norm_vdelay(v4l2_std_id norm)
@@ -636,7 +648,7 @@ static inline unsigned int norm_fsc8(v4l2_std_id norm)
 	if (norm & V4L2_STD_PAL_M)
 		return 28604892;      // 3.575611 MHz
 
-	if (norm & (V4L2_STD_PAL_Nc))
+	if (norm & V4L2_STD_PAL_Nc)
 		return 28656448;      // 3.582056 MHz
 
 	if (norm & V4L2_STD_NTSC) // All NTSC/M and variants
@@ -841,8 +853,8 @@ static int set_tvaudio(struct cx88_core *core)
 	} else if (V4L2_STD_SECAM_DK & norm) {
 		core->tvaudio = WW_DK;
 
-	} else if ((V4L2_STD_NTSC_M & norm) ||
-		   (V4L2_STD_PAL_M  & norm)) {
+	} else if ((V4L2_STD_NTSC_M | V4L2_STD_PAL_M | V4L2_STD_PAL_Nc) &
+		   norm) {
 		core->tvaudio = WW_BTSC;
 
 	} else if (V4L2_STD_NTSC_M_JP & norm) {
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/2 media: usbtv: Add PAL-Nc standard

In reply to Jorge Maidana

Add PAL-Nc support to usbtv, the corresponding register value "0x00fe" comes from the Windows driver "Active Development Co., Ltd. v2.1.1.2".

---
 drivers/media/usb/usbtv/usbtv-video.c | 5 ++++-
 drivers/media/usb/usbtv/usbtv.h       | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/media/usb/usbtv/usbtv-video.c +4 -1
index a714ad77c..1e30e0595 100644
@@ -136,6 +136,8 @@ static uint16_t usbtv_norm_to_16f_reg(v4l2_std_id norm)
 		return 0x00a8;
 	if (norm & (V4L2_STD_PAL_M | V4L2_STD_PAL_60))
 		return 0x00bc;
+	if (norm & V4L2_STD_PAL_Nc)
+		return 0x00fe;
 	/* Fallback to automatic detection for other standards */
 	return 0x0000;
 }
@@ -241,7 +243,8 @@ static int usbtv_select_norm(struct usbtv *usbtv, v4l2_std_id norm)
 		static const v4l2_std_id ntsc_mask =
 			V4L2_STD_NTSC | V4L2_STD_NTSC_443;
 		static const v4l2_std_id pal_mask =
-			V4L2_STD_PAL | V4L2_STD_PAL_60 | V4L2_STD_PAL_M;
+			V4L2_STD_PAL | V4L2_STD_PAL_60 | V4L2_STD_PAL_M |
+			V4L2_STD_PAL_Nc;
 
 		if (norm & ntsc_mask)
 			ret = usbtv_set_regs(usbtv, ntsc, ARRAY_SIZE(ntsc));
drivers/media/usb/usbtv/usbtv.h +2 -1
index 77a368e90..b9fa7c008 100644
@@ -68,7 +68,8 @@
 #define USBTV_ODD(chunk)	((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15)
 #define USBTV_CHUNK_NO(chunk)	(be32_to_cpu(chunk[0]) & 0x00000fff)
 
-#define USBTV_TV_STD  (V4L2_STD_525_60 | V4L2_STD_PAL | V4L2_STD_SECAM)
+#define USBTV_TV_STD		(V4L2_STD_525_60 | V4L2_STD_PAL | \
+				 V4L2_STD_PAL_Nc | V4L2_STD_SECAM)
 
 /* parameters for supported TV norms */
 struct usbtv_norm_params {
Signature · 1 line
2.30.2