aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/saa7111.c49
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
95static inline void
96saa7111_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
99static int 106static int
100saa7111_write_block (struct i2c_client *client, 107saa7111_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);