diff options
author | Russell King <rmk@arm.linux.org.uk> | 2007-05-26 06:55:32 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-06-08 07:21:12 -0400 |
commit | 624fc7f52b48f69fd9d1fe7a594c211762c89825 (patch) | |
tree | ef26093d4dfc7d3009c5db0c753d7df86757ce16 /drivers/media/video/saa7111.c | |
parent | 05f85839a2ffcaa75d505526ca8e74097be18d8c (diff) |
V4L/DVB (5700): Saa7111: fix picture settings cache bug
If the SAA7111 device is powered down, and requires re-initialisation when
the V4L device is opened (as on the NetWinder), the SAA7111 driver gets
completely confused about the current settings.
The problem is centred around the way the driver keeps _two_ cached copies
of the current settings - one of the struct video_picture settings, and one
of the registers.
When the decoder is re-initailised, the cached register settings are
overwritten, as are the values in the hardware registers. However, the
cached video_picture settings are not.
Resolve this by removing the useless and buggy second level of caching for
video_picture. Instead, provide a function which updates register values
if and only if the value we are going to write to the register has changed.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/saa7111.c')
-rw-r--r-- | drivers/media/video/saa7111.c | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 74839f98b7c4..c1a392e47170 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c | |||
@@ -75,10 +75,6 @@ struct saa7111 { | |||
75 | int norm; | 75 | int norm; |
76 | int input; | 76 | int input; |
77 | int enable; | 77 | int enable; |
78 | int bright; | ||
79 | int contrast; | ||
80 | int hue; | ||
81 | int sat; | ||
82 | }; | 78 | }; |
83 | 79 | ||
84 | #define I2C_SAA7111 0x48 | 80 | #define I2C_SAA7111 0x48 |
@@ -96,6 +92,17 @@ saa7111_write (struct i2c_client *client, | |||
96 | return i2c_smbus_write_byte_data(client, reg, value); | 92 | return i2c_smbus_write_byte_data(client, reg, value); |
97 | } | 93 | } |
98 | 94 | ||
95 | static inline void | ||
96 | saa7111_write_if_changed(struct i2c_client *client, u8 reg, u8 value) | ||
97 | { | ||
98 | struct saa7111 *decoder = i2c_get_clientdata(client); | ||
99 | |||
100 | if (decoder->reg[reg] != value) { | ||
101 | decoder->reg[reg] = value; | ||
102 | i2c_smbus_write_byte_data(client, reg, value); | ||
103 | } | ||
104 | } | ||
105 | |||
99 | static int | 106 | static int |
100 | saa7111_write_block (struct i2c_client *client, | 107 | saa7111_write_block (struct i2c_client *client, |
101 | const u8 *data, | 108 | const u8 *data, |
@@ -439,28 +446,14 @@ saa7111_command (struct i2c_client *client, | |||
439 | { | 446 | { |
440 | struct video_picture *pic = arg; | 447 | struct video_picture *pic = arg; |
441 | 448 | ||
442 | if (decoder->bright != pic->brightness) { | 449 | /* We want 0 to 255 we get 0-65535 */ |
443 | /* We want 0 to 255 we get 0-65535 */ | 450 | saa7111_write_if_changed(client, 0x0a, pic->brightness >> 8); |
444 | decoder->bright = pic->brightness; | 451 | /* We want 0 to 127 we get 0-65535 */ |
445 | saa7111_write(client, 0x0a, decoder->bright >> 8); | 452 | saa7111_write(client, 0x0b, pic->contrast >> 9); |
446 | } | 453 | /* We want 0 to 127 we get 0-65535 */ |
447 | if (decoder->contrast != pic->contrast) { | 454 | saa7111_write(client, 0x0c, pic->colour >> 9); |
448 | /* We want 0 to 127 we get 0-65535 */ | 455 | /* We want -128 to 127 we get 0-65535 */ |
449 | decoder->contrast = pic->contrast; | 456 | saa7111_write(client, 0x0d, (pic->hue - 32768) >> 8); |
450 | saa7111_write(client, 0x0b, | ||
451 | decoder->contrast >> 9); | ||
452 | } | ||
453 | if (decoder->sat != pic->colour) { | ||
454 | /* We want 0 to 127 we get 0-65535 */ | ||
455 | decoder->sat = pic->colour; | ||
456 | saa7111_write(client, 0x0c, decoder->sat >> 9); | ||
457 | } | ||
458 | if (decoder->hue != pic->hue) { | ||
459 | /* We want -128 to 127 we get 0-65535 */ | ||
460 | decoder->hue = pic->hue; | ||
461 | saa7111_write(client, 0x0d, | ||
462 | (decoder->hue - 32768) >> 8); | ||
463 | } | ||
464 | } | 457 | } |
465 | break; | 458 | break; |
466 | 459 | ||
@@ -524,10 +517,6 @@ saa7111_detect_client (struct i2c_adapter *adapter, | |||
524 | decoder->norm = VIDEO_MODE_NTSC; | 517 | decoder->norm = VIDEO_MODE_NTSC; |
525 | decoder->input = 0; | 518 | decoder->input = 0; |
526 | decoder->enable = 1; | 519 | decoder->enable = 1; |
527 | decoder->bright = 32768; | ||
528 | decoder->contrast = 32768; | ||
529 | decoder->hue = 32768; | ||
530 | decoder->sat = 32768; | ||
531 | i2c_set_clientdata(client, decoder); | 520 | i2c_set_clientdata(client, decoder); |
532 | 521 | ||
533 | i = i2c_attach_client(client); | 522 | i = i2c_attach_client(client); |