[PATCH] media: i2c: saa7115: only select SECAM for SECAM-only standard sets
From: Martin Blumenstingl
Date: Sun Nov 15 2026 - 17:45:41 EST
For the SAA7111(A), SAA7113 and GM7113C the chroma standard (CSTD bits
of register 0x0e) is selected in saa711x_set_v4lstd(). Since commit
a9aaec4e83e6 ("V4L/DVB (5408): Fix SECAM handling on saa7115") SECAM
is chosen as soon as the requested set contains any SECAM standard,
even if the set also contains PAL or NTSC standards.
Such mixed sets are passed to the driver in normal use: for these chips
saa711x_querystd() can only determine the number of lines, so on a
625-line signal VIDIOC_QUERYSTD returns all of V4L2_STD_625_50 (PAL,
PAL-N, PAL-Nc and SECAM). An application which sets the detected
standard (v4l2-ctl does this before streaming) then gets SECAM decoding
of a PAL signal. On an SAA7113 this results in a picture without
colour (U and V are a constant 128) and RDCAP in status byte 2 is
cleared, so saa711x_g_input_status() reports V4L2_IN_ST_NO_SIGNAL even
though the decoder is locked to the signal.
The intention of the original change was most likely that a single
SECAM variant (for example V4L2_STD_SECAM_L) selects SECAM as well, not
only the whole V4L2_STD_SECAM group. Keep that, but only select SECAM
when the set consists of SECAM standards only. For 625-line sets this
is the same condition the saa7127 driver uses for its SECAM
configuration, and for the sets applications pass in practice
(VIDIOC_QUERYSTD results, V4L2_STD_ALL or single standards) it gives
the same result as other decoder drivers such as tvp5150 and adv7180,
which test for SECAM only after PAL and NTSC.
Mixed sets now keep CSTD = 000 (PAL BGDHI for 50 Hz, NTSC M for 60 Hz),
which matches the behaviour before that commit. This also stops the
driver from programming CSTD = 101 for 60 Hz when a set such as
V4L2_STD_ALL is requested, which is reserved on the SAA7113 and selects
PAL 4.43 on the SAA7111A.
While here, document CSTD = 101 in the table above the code and add a
comment that CSTD = 000 is used when none of the cases match. CSTD = 101
is listed in table 42 ("Chrominance control subaddress 0Eh") of the
SAA7113H data sheet (Rev. 02, 9 May 2005) and in table 26 ("Chrominance
control SA0E") of the SAA7111A data sheet (1998 May 15).
Link: https://www.mouser.lt/datasheet/2/302/SAA7113H_2-87651.pdf
Link: https://www.eecg.toronto.edu/~tm4/SAA7111A_4.pdf
Fixes: a9aaec4e83e6 ("V4L/DVB (5408): Fix SECAM handling on saa7115")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@xxxxxxxxxxxxxx>
---
drivers/media/i2c/saa7115.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index f4015f11367b..a33487d37d08 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -1007,11 +1007,16 @@ static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std)
010 Combination-PAL N (3.58MHz) NTSC 4.43 (60 Hz)
011 NTSC N (3.58MHz) PAL M (3.58MHz)
100 reserved NTSC-Japan (3.58MHz)
+ 101 SECAM (50 Hz) reserved (SAA7111A: PAL 4.43)
*/
if (state->ident <= SAA7113 ||
state->ident == GM7113C) {
u8 reg = saa711x_read(sd, R_0E_CHROMA_CNTL_1) & 0x8f;
+ /*
+ * CSTD is cleared above, so it is 000 (PAL BGDHI for 50 Hz,
+ * NTSC M for 60 Hz) unless one of the cases below matches.
+ */
if (std == V4L2_STD_PAL_M) {
reg |= 0x30;
} else if (std == V4L2_STD_PAL_Nc) {
@@ -1020,7 +1025,8 @@ static void saa711x_set_v4lstd(struct v4l2_subdev *sd, v4l2_std_id std)
reg |= 0x10;
} else if (std == V4L2_STD_NTSC_M_JP) {
reg |= 0x40;
- } else if (std & V4L2_STD_SECAM) {
+ } else if ((std & V4L2_STD_SECAM) &&
+ !(std & ~V4L2_STD_SECAM)) {
reg |= 0x50;
}
saa711x_write(sd, R_0E_CHROMA_CNTL_1, reg);
--
2.56.1