public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] media: cx88 and usbtv: PAL-Nc fixes
@ 2022-05-13 18:29 Jorge Maidana
  2022-05-13 18:29 ` [PATCH 1/2] media: cx88: Fix PAL-Nc standard Jorge Maidana
  2022-05-13 18:29 ` [PATCH 2/2] media: usbtv: Add " Jorge Maidana
  0 siblings, 2 replies; 3+ messages in thread
From: Jorge Maidana @ 2022-05-13 18:29 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, Jorge Maidana

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(-)

-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] media: cx88: Fix PAL-Nc standard
  2022-05-13 18:29 [PATCH 0/2] media: cx88 and usbtv: PAL-Nc fixes Jorge Maidana
@ 2022-05-13 18:29 ` Jorge Maidana
  2022-05-13 18:29 ` [PATCH 2/2] media: usbtv: Add " Jorge Maidana
  1 sibling, 0 replies; 3+ messages in thread
From: Jorge Maidana @ 2022-05-13 18:29 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, Jorge Maidana

* 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.

Signed-off-by: Jorge Maidana <jorgem.linux@gmail.com>
---
 drivers/media/pci/cx88/cx88-core.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c
index 89d4d5a3b..52be42f9a 100644
--- a/drivers/media/pci/cx88/cx88-core.c
+++ b/drivers/media/pci/cx88/cx88-core.c
@@ -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) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] media: usbtv: Add PAL-Nc standard
  2022-05-13 18:29 [PATCH 0/2] media: cx88 and usbtv: PAL-Nc fixes Jorge Maidana
  2022-05-13 18:29 ` [PATCH 1/2] media: cx88: Fix PAL-Nc standard Jorge Maidana
@ 2022-05-13 18:29 ` Jorge Maidana
  1 sibling, 0 replies; 3+ messages in thread
From: Jorge Maidana @ 2022-05-13 18:29 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, 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".

Signed-off-by: Jorge Maidana <jorgem.linux@gmail.com>
---
 drivers/media/usb/usbtv/usbtv-video.c | 5 ++++-
 drivers/media/usb/usbtv/usbtv.h       | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index a714ad77c..1e30e0595 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -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));
diff --git a/drivers/media/usb/usbtv/usbtv.h b/drivers/media/usb/usbtv/usbtv.h
index 77a368e90..b9fa7c008 100644
--- a/drivers/media/usb/usbtv/usbtv.h
+++ b/drivers/media/usb/usbtv/usbtv.h
@@ -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 {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-13 18:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-13 18:29 [PATCH 0/2] media: cx88 and usbtv: PAL-Nc fixes Jorge Maidana
2022-05-13 18:29 ` [PATCH 1/2] media: cx88: Fix PAL-Nc standard Jorge Maidana
2022-05-13 18:29 ` [PATCH 2/2] media: usbtv: Add " Jorge Maidana

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox