Skip to contentSkip to conversation

media: i2c: adv7180: fix reserved bit in Video Selection 2

PATCH In review Benjamin Marty 3 participants 8 messages May 12, 2022 – May 18, 2022

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

PATCH v2 1/1 media: i2c: adv7180: fix reserved bit in Video Selection 2

This bit is marked as reserved in the ADV Hardware Reference Manual.

Resetting this bit seems to cause increased video noise. Setting this bit according to the Hardware Reference Manual reduces the video noise immediately.

---
version 2:
- Fixed Kieran's remarks

 drivers/media/i2c/adv7180.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7180.c +4 -1
index 4f5db195e66d..992111fe249e 100644
@@ -43,6 +43,7 @@
 #define ADV7180_INPUT_CONTROL_INSEL_MASK		0x0f
 
 #define ADV7182_REG_INPUT_VIDSEL			0x0002
+#define ADV7182_REG_INPUT_RESERVED			BIT(2)
 
 #define ADV7180_REG_OUTPUT_CONTROL			0x0003
 #define ADV7180_REG_EXTENDED_OUTPUT_CONTROL		0x0004
@@ -1014,7 +1015,9 @@ static int adv7182_init(struct adv7180_state *state)
 
 static int adv7182_set_std(struct adv7180_state *state, unsigned int std)
 {
-	return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL, std << 4);
+	/* Failing to set the reserved bit can result in increased video noise */
+	return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL,
+			     (std << 4) | ADV7182_REG_INPUT_RESERVED);
 }
 
 enum adv7182_input_type {
Signature · 1 line
2.36.1
Reviewed-by on v2 1/1
#1 lore raw

Hi Benjamin.

Quoted 20 lines · Benjamin Marty

This bit is marked as reserved in the ADV Hardware Reference Manual.

Resetting this bit seems to cause increased video noise. Setting this bit according to the Hardware Reference Manual reduces the video noise immediately.

---
version 2:
- Fixed Kieran's remarks

 drivers/media/i2c/adv7180.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7180.c +0 -0
index 4f5db195e66d..992111fe249e 100644

drivers/media/i2c/adv7180.c line 46

Quoted 4 lines
drivers/media/i2c/adv7180.c +1 -0
@@ -43,6 +43,7 @@
 #define ADV7180_INPUT_CONTROL_INSEL_MASK               0x0f
 
 #define ADV7182_REG_INPUT_VIDSEL                       0x0002
+#define ADV7182_REG_INPUT_RESERVED                     BIT(2)

Responding to Kieran's comment on V1:

Quoted 5 lines
drivers/media/i2c/adv7180.c +0 -0
 If the bit is documented with a better name, then use that of course,

otherwise perhaps even a comment in the code saying that failing to set the bit increases visible noise would be suitable. (or that setting the bit reduces noise, I guess it depends on if you think this bit is performing noise reduction, or if not setting it is introducing noise)

I went digging through the datasheet for this info as I care about ADV728[0|1|2]M.

https://www.analog.com/media/en/technical-documentation/data-sheets/ADV7182.pdf
page 68 defines bits 0-3 as reserved, and "set to default" which is 0100b.
https://www.analog.com/media/en/technical-documentation/user-guides/ADV7280_7281_7282_7283_UG-637.pdf
page 70 says the same for ADV7280/ADV7281/ADV7282/ADV7283.

So no name or detail in the docs over what the bits do.

The patch does mean the driver more closely follows the datasheet, so it looks good to me.

I'll try to find a couple of minutes to get my hardware out and confirm I see the change in video noise.

Dave

Quoted 16 lines

#define ADV7180_REG_OUTPUT_CONTROL 0x0003
#define ADV7180_REG_EXTENDED_OUTPUT_CONTROL 0x0004

drivers/media/i2c/adv7180.c +3 -2
@@ -1014,7 +1015,9 @@ static int adv7182_init(struct adv7180_state *state)
 
 static int adv7182_set_std(struct adv7180_state *state, unsigned int std)
 {
-       return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL, std << 4);
+       /* Failing to set the reserved bit can result in increased video noise */
+       return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL,
+                            (std << 4) | ADV7182_REG_INPUT_RESERVED);
 }
 
 enum adv7182_input_type {
--

2.36.1

Reviewed-by
#2 lore raw

Quoting Dave Stevenson (2022-05-12 14:56:45)

Quoted 46 lines

Hi Benjamin.

Quoted 20 lines · Benjamin Marty

This bit is marked as reserved in the ADV Hardware Reference Manual.

Resetting this bit seems to cause increased video noise. Setting this bit according to the Hardware Reference Manual reduces the video noise immediately.

---
version 2:
- Fixed Kieran's remarks

 drivers/media/i2c/adv7180.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7180.c +0 -0
index 4f5db195e66d..992111fe249e 100644

drivers/media/i2c/adv7180.c line 46

Quoted 4 lines
drivers/media/i2c/adv7180.c +1 -0
@@ -43,6 +43,7 @@
 #define ADV7180_INPUT_CONTROL_INSEL_MASK               0x0f
 
 #define ADV7182_REG_INPUT_VIDSEL                       0x0002
+#define ADV7182_REG_INPUT_RESERVED                     BIT(2)

Responding to Kieran's comment on V1:

Quoted 5 lines
drivers/media/i2c/adv7180.c +0 -0
 If the bit is documented with a better name, then use that of course,

otherwise perhaps even a comment in the code saying that failing to set the bit increases visible noise would be suitable. (or that setting the bit reduces noise, I guess it depends on if you think this bit is performing noise reduction, or if not setting it is introducing noise)

I went digging through the datasheet for this info as I care about ADV728[0|1|2]M.

https://www.analog.com/media/en/technical-documentation/data-sheets/ADV7182.pdf
page 68 defines bits 0-3 as reserved, and "set to default" which is 0100b.
https://www.analog.com/media/en/technical-documentation/user-guides/ADV7280_7281_7282_7283_UG-637.pdf
page 70 says the same for ADV7280/ADV7281/ADV7282/ADV7283.

So no name or detail in the docs over what the bits do.

Quoted 7 lines

The patch does mean the driver more closely follows the datasheet, so it looks good to me.

I'll try to find a couple of minutes to get my hardware out and confirm I see the change in video noise.

Great, Is there any way we can identify (easily?) if this is introducing noise reduction, or preventing noise being added?

If it's introducing noise reduction, as a feature, that's quite different to causing noise if it's not set ... (Unless perhaps people have a desire to add noise :D)

But I think I could add this already:

Quoted 19 lines

Dave

Quoted 16 lines

#define ADV7180_REG_OUTPUT_CONTROL 0x0003
#define ADV7180_REG_EXTENDED_OUTPUT_CONTROL 0x0004

drivers/media/i2c/adv7180.c +3 -2
@@ -1014,7 +1015,9 @@ static int adv7182_init(struct adv7180_state *state)
 
 static int adv7182_set_std(struct adv7180_state *state, unsigned int std)
 {
-       return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL, std << 4);
+       /* Failing to set the reserved bit can result in increased video noise */
+       return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL,
+                            (std << 4) | ADV7182_REG_INPUT_RESERVED);
 }
 
 enum adv7182_input_type {
--

2.36.1

Tested-by
#3 lore raw
Quoted 56 lines · Kieran Bingham

Quoting Dave Stevenson (2022-05-12 14:56:45)

Quoted 46 lines

Hi Benjamin.

Quoted 20 lines · Benjamin Marty

This bit is marked as reserved in the ADV Hardware Reference Manual.

Resetting this bit seems to cause increased video noise. Setting this bit according to the Hardware Reference Manual reduces the video noise immediately.

---
version 2:
- Fixed Kieran's remarks

 drivers/media/i2c/adv7180.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7180.c +0 -0
index 4f5db195e66d..992111fe249e 100644

drivers/media/i2c/adv7180.c line 46

Quoted 4 lines
drivers/media/i2c/adv7180.c +1 -0
@@ -43,6 +43,7 @@
 #define ADV7180_INPUT_CONTROL_INSEL_MASK               0x0f
 
 #define ADV7182_REG_INPUT_VIDSEL                       0x0002
+#define ADV7182_REG_INPUT_RESERVED                     BIT(2)

Responding to Kieran's comment on V1:

Quoted 5 lines
drivers/media/i2c/adv7180.c +0 -0
 If the bit is documented with a better name, then use that of course,

otherwise perhaps even a comment in the code saying that failing to set the bit increases visible noise would be suitable. (or that setting the bit reduces noise, I guess it depends on if you think this bit is performing noise reduction, or if not setting it is introducing noise)

I went digging through the datasheet for this info as I care about ADV728[0|1|2]M.

https://www.analog.com/media/en/technical-documentation/data-sheets/ADV7182.pdf
page 68 defines bits 0-3 as reserved, and "set to default" which is 0100b.
https://www.analog.com/media/en/technical-documentation/user-guides/ADV7280_7281_7282_7283_UG-637.pdf
page 70 says the same for ADV7280/ADV7281/ADV7282/ADV7283.

So no name or detail in the docs over what the bits do.

Quoted 7 lines

The patch does mean the driver more closely follows the datasheet, so it looks good to me.

I'll try to find a couple of minutes to get my hardware out and confirm I see the change in video noise.

Quoted 6 lines

Great, Is there any way we can identify (easily?) if this is introducing noise reduction, or preventing noise being added?

If it's introducing noise reduction, as a feature, that's quite different to causing noise if it's not set ... (Unless perhaps people have a desire to add noise :D)

OK, I dug out my hardware. I'm doing the nasty with:
i2ctransfer -y -f 10 w2@0x21 0x02 0x84
and
i2ctransfer -y -f 10 w2@0x21 0x02 0x80
to flip back and forth between the two settings on my PAL source.

It does reduce the noise, but also softens the image significantly.

As slightly iffy photos to show the difference
https://photos.app.goo.gl/hLKxv3TP93gX864y8 is the new setting.
https://photos.app.goo.gl/sWxEhdvxHLUkGL1C8 is the old setting. (Yes it's a very old F1 race that happened to be on this DVD/HDD recorder).

I couldn't honestly say I prefer one over the other (analogue video really is grim!), but it does mean that we're following the datasheet more accurately, so:

Quoted 24 lines

But I think I could add this already:

Quoted 19 lines

Dave

Quoted 16 lines

#define ADV7180_REG_OUTPUT_CONTROL 0x0003
#define ADV7180_REG_EXTENDED_OUTPUT_CONTROL 0x0004

drivers/media/i2c/adv7180.c +3 -2
@@ -1014,7 +1015,9 @@ static int adv7182_init(struct adv7180_state *state)
 
 static int adv7182_set_std(struct adv7180_state *state, unsigned int std)
 {
-       return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL, std << 4);
+       /* Failing to set the reserved bit can result in increased video noise */
+       return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL,
+                            (std << 4) | ADV7182_REG_INPUT_RESERVED);
 }
 
 enum adv7182_input_type {
--

2.36.1

#4 lore raw

Quoting Dave Stevenson (2022-05-17 18:50:11)

Quoted 71 lines
Quoted 56 lines · Kieran Bingham

Quoting Dave Stevenson (2022-05-12 14:56:45)

Quoted 46 lines

Hi Benjamin.

Quoted 20 lines · Benjamin Marty

This bit is marked as reserved in the ADV Hardware Reference Manual.

Resetting this bit seems to cause increased video noise. Setting this bit according to the Hardware Reference Manual reduces the video noise immediately.

---
version 2:
- Fixed Kieran's remarks

 drivers/media/i2c/adv7180.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7180.c +0 -0
index 4f5db195e66d..992111fe249e 100644

drivers/media/i2c/adv7180.c line 46

Quoted 4 lines
drivers/media/i2c/adv7180.c +1 -0
@@ -43,6 +43,7 @@
 #define ADV7180_INPUT_CONTROL_INSEL_MASK               0x0f
 
 #define ADV7182_REG_INPUT_VIDSEL                       0x0002
+#define ADV7182_REG_INPUT_RESERVED                     BIT(2)

Responding to Kieran's comment on V1:

Quoted 5 lines
drivers/media/i2c/adv7180.c +0 -0
 If the bit is documented with a better name, then use that of course,

otherwise perhaps even a comment in the code saying that failing to set the bit increases visible noise would be suitable. (or that setting the bit reduces noise, I guess it depends on if you think this bit is performing noise reduction, or if not setting it is introducing noise)

I went digging through the datasheet for this info as I care about ADV728[0|1|2]M.

https://www.analog.com/media/en/technical-documentation/data-sheets/ADV7182.pdf
page 68 defines bits 0-3 as reserved, and "set to default" which is 0100b.
https://www.analog.com/media/en/technical-documentation/user-guides/ADV7280_7281_7282_7283_UG-637.pdf
page 70 says the same for ADV7280/ADV7281/ADV7282/ADV7283.

So no name or detail in the docs over what the bits do.

Quoted 7 lines

The patch does mean the driver more closely follows the datasheet, so it looks good to me.

I'll try to find a couple of minutes to get my hardware out and confirm I see the change in video noise.

Quoted 6 lines

Great, Is there any way we can identify (easily?) if this is introducing noise reduction, or preventing noise being added?

If it's introducing noise reduction, as a feature, that's quite different to causing noise if it's not set ... (Unless perhaps people have a desire to add noise :D)

OK, I dug out my hardware. I'm doing the nasty with:
i2ctransfer -y -f 10 w2@0x21 0x02 0x84
and
i2ctransfer -y -f 10 w2@0x21 0x02 0x80
to flip back and forth between the two settings on my PAL source.

Quoted 6 lines

It does reduce the noise, but also softens the image significantly.

As slightly iffy photos to show the difference
https://photos.app.goo.gl/hLKxv3TP93gX864y8 is the new setting.
https://photos.app.goo.gl/sWxEhdvxHLUkGL1C8 is the old setting. (Yes it's a very old F1 race that happened to be on this DVD/HDD recorder).

It's a really tough test case, as I expect these are frame captures from two separate time points, rather than some paused frame, but I would say the text on the old setting is clearer. That could easily be due to differences in the actual content though.

It might make me think this should be a control that could be dynamically set to allow the user to decide...

Benjamin, how does it look on your system? I presume setting this bit improves image quality for your use case.

Quoted 10 lines

I couldn't honestly say I prefer one over the other (analogue video really is grim!), but it does mean that we're following the datasheet more accurately, so:

Quoted 4 lines

But I think I could add this already:

From a driver perspective, with no other existing expecatation - I would say matching the datasheet is the correct thing to do anyway.

--
Kieran

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

Dave

Quoted 16 lines

#define ADV7180_REG_OUTPUT_CONTROL 0x0003
#define ADV7180_REG_EXTENDED_OUTPUT_CONTROL 0x0004

drivers/media/i2c/adv7180.c +3 -2
@@ -1014,7 +1015,9 @@ static int adv7182_init(struct adv7180_state *state)
 
 static int adv7182_set_std(struct adv7180_state *state, unsigned int std)
 {
-       return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL, std << 4);
+       /* Failing to set the reserved bit can result in increased video noise */
+       return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL,
+                            (std << 4) | ADV7182_REG_INPUT_RESERVED);
 }
 
 enum adv7182_input_type {
--

2.36.1

#5 lore raw
Quoted 80 lines · Kieran Bingham

Quoting Dave Stevenson (2022-05-17 18:50:11)

Quoted 71 lines
Quoted 56 lines · Kieran Bingham

Quoting Dave Stevenson (2022-05-12 14:56:45)

Quoted 46 lines

Hi Benjamin.

Quoted 20 lines · Benjamin Marty

This bit is marked as reserved in the ADV Hardware Reference Manual.

Resetting this bit seems to cause increased video noise. Setting this bit according to the Hardware Reference Manual reduces the video noise immediately.

---
version 2:
- Fixed Kieran's remarks

 drivers/media/i2c/adv7180.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7180.c +0 -0
index 4f5db195e66d..992111fe249e 100644

drivers/media/i2c/adv7180.c line 46

Quoted 4 lines
drivers/media/i2c/adv7180.c +1 -0
@@ -43,6 +43,7 @@
 #define ADV7180_INPUT_CONTROL_INSEL_MASK               0x0f
 
 #define ADV7182_REG_INPUT_VIDSEL                       0x0002
+#define ADV7182_REG_INPUT_RESERVED                     BIT(2)

Responding to Kieran's comment on V1:

Quoted 5 lines
drivers/media/i2c/adv7180.c +0 -0
 If the bit is documented with a better name, then use that of course,

otherwise perhaps even a comment in the code saying that failing to set the bit increases visible noise would be suitable. (or that setting the bit reduces noise, I guess it depends on if you think this bit is performing noise reduction, or if not setting it is introducing noise)

I went digging through the datasheet for this info as I care about ADV728[0|1|2]M.

https://www.analog.com/media/en/technical-documentation/data-sheets/ADV7182.pdf
page 68 defines bits 0-3 as reserved, and "set to default" which is 0100b.
https://www.analog.com/media/en/technical-documentation/user-guides/ADV7280_7281_7282_7283_UG-637.pdf
page 70 says the same for ADV7280/ADV7281/ADV7282/ADV7283.

So no name or detail in the docs over what the bits do.

Quoted 7 lines

The patch does mean the driver more closely follows the datasheet, so it looks good to me.

I'll try to find a couple of minutes to get my hardware out and confirm I see the change in video noise.

Quoted 6 lines

Great, Is there any way we can identify (easily?) if this is introducing noise reduction, or preventing noise being added?

If it's introducing noise reduction, as a feature, that's quite different to causing noise if it's not set ... (Unless perhaps people have a desire to add noise :D)

OK, I dug out my hardware. I'm doing the nasty with:
i2ctransfer -y -f 10 w2@0x21 0x02 0x84
and
i2ctransfer -y -f 10 w2@0x21 0x02 0x80
to flip back and forth between the two settings on my PAL source.

Quoted 6 lines

It does reduce the noise, but also softens the image significantly.

As slightly iffy photos to show the difference
https://photos.app.goo.gl/hLKxv3TP93gX864y8 is the new setting.
https://photos.app.goo.gl/sWxEhdvxHLUkGL1C8 is the old setting. (Yes it's a very old F1 race that happened to be on this DVD/HDD recorder).

Quoted 4 lines

It's a really tough test case, as I expect these are frame captures from two separate time points, rather than some paused frame, but I would say the text on the old setting is clearer. That could easily be due to differences in the actual content though.

Yes the frames are from a few seconds apart as I thought I'd left the remote at home (actually I hadn't). I'll recapture them later today for the same frame from a better source (probably a DVD). The current settings are sharper, but significantly noisier.

Quoted 13 lines

It might make me think this should be a control that could be dynamically set to allow the user to decide...

Benjamin, how does it look on your system? I presume setting this bit improves image quality for your use case.

Quoted 6 lines

I couldn't honestly say I prefer one over the other (analogue video really is grim!), but it does mean that we're following the datasheet more accurately, so:

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

But I think I could add this already:

From a driver perspective, with no other existing expecatation - I would say matching the datasheet is the correct thing to do anyway.

That's my view too.

Dave

Quoted 25 lines

--
Kieran

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines

Dave

Quoted 16 lines

#define ADV7180_REG_OUTPUT_CONTROL 0x0003
#define ADV7180_REG_EXTENDED_OUTPUT_CONTROL 0x0004

drivers/media/i2c/adv7180.c +3 -2
@@ -1014,7 +1015,9 @@ static int adv7182_init(struct adv7180_state *state)
 
 static int adv7182_set_std(struct adv7180_state *state, unsigned int std)
 {
-       return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL, std << 4);
+       /* Failing to set the reserved bit can result in increased video noise */
+       return adv7180_write(state, ADV7182_REG_INPUT_VIDSEL,
+                            (std << 4) | ADV7182_REG_INPUT_RESERVED);
 }
 
 enum adv7182_input_type {
--

2.36.1

#6 lore raw
In reply to Kieran Bingham

Am Mi., 18. Mai 2022 um 01:09 Uhr schrieb Kieran Bingham <[email protected]>:

Quoted 2 lines

Benjamin, how does it look on your system? I presume setting this bit improves image quality for your use case.

Yes, it fixes the analog noise/grain issue. I have noticed too that the image is getting softer, as described by Dave.

Comparison Images from my side (Not the exact same frame):
https://drive.google.com/file/d/1gdwKUGb7GcvMVJG0uSomhMPeSfDwXId-
https://drive.google.com/file/d/1oitfhl4txzxOabI-TplpsKMqP2mr0TKy

Quoted 2 lines

From a driver perspective, with no other existing expecatation - I would say matching the datasheet is the correct thing to do anyway.

I'm also agreeing on the driver should be complying with the Datasheet. I think it's a "Bug" and not a "Feature" that the Image gets sharpened but more grainy when not setting this bit.

Furthermore, I have opened a Ticket at ADV to get more details, but I'm not really expecting a proper Answer.

Benjamin

#7 lore raw
Quoted 6 lines · Benjamin Marty

Am Mi., 18. Mai 2022 um 01:09 Uhr schrieb Kieran Bingham <[email protected]>:

Quoted 2 lines

Benjamin, how does it look on your system? I presume setting this bit improves image quality for your use case.

Quoted 6 lines

Yes, it fixes the analog noise/grain issue. I have noticed too that the image is getting softer, as described by Dave.

Comparison Images from my side (Not the exact same frame):
https://drive.google.com/file/d/1gdwKUGb7GcvMVJG0uSomhMPeSfDwXId-
https://drive.google.com/file/d/1oitfhl4txzxOabI-TplpsKMqP2mr0TKy

More exciting images from me, and they are from the same frame (DVD paused)
https://photos.app.goo.gl/ztbW6uf6C8AguVnz7 for some stills from Tom & Jerry, and the Fantastic 4.
The first image in each case is the register at 0x84 (new setting), and the second as 0x80 (old setting).

The final images from Fantastic 4 are the most telling. The old setting produces a lot of crawling noise on the land areas of the earth, whilst with the new setting that is almost totally gone, so on that basis I'd vote for the new.

I should add that I am using the I2P block in the chip to deinterlace the source. From what I understand of the I2P it's a pretty simple line doubling so that won't overly help image quality, but shouldn't make a difference in this case.

Dave

Quoted 11 lines
Quoted 2 lines

From a driver perspective, with no other existing expecatation - I would say matching the datasheet is the correct thing to do anyway.

I'm also agreeing on the driver should be complying with the Datasheet. I think it's a "Bug" and not a "Feature" that the Image gets sharpened but more grainy when not setting this bit.

Furthermore, I have opened a Ticket at ADV to get more details, but I'm not really expecting a proper Answer.

Benjamin