aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134/saa6752hs.c
diff options
context:
space:
mode:
authorRobert W. Boone <rboone@rtd.com>2005-11-09 00:36:45 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:12 -0500
commit9b71521b66da26129255ade6ad71f708032bc0e0 (patch)
tree3b7092a636f91e8df933ddb2e7e4fe412e5d68d4 /drivers/media/video/saa7134/saa6752hs.c
parent20f441f6900d786606583263d89653c48c7093a8 (diff)
[PATCH] v4l: 686: change the number of lines in the input signal when the
- Change the number of lines in the input signal when the video standard is changed. - Fix comments style. Signed-off-by: Robert W. Boone <rboone@rtd.com> Signed-off-by: Nickolay V. Shmyrev <nshmyrev@yandex.ru> Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/video/saa7134/saa6752hs.c')
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c130
1 files changed, 70 insertions, 60 deletions
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index 382911c6ef2..dac720ea3b0 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -57,6 +57,7 @@ struct saa6752hs_state {
57 struct i2c_client client; 57 struct i2c_client client;
58 struct v4l2_mpeg_compression params; 58 struct v4l2_mpeg_compression params;
59 enum saa6752hs_videoformat video_format; 59 enum saa6752hs_videoformat video_format;
60 v4l2_std_id standard;
60}; 61};
61 62
62enum saa6752hs_command { 63enum saa6752hs_command {
@@ -74,58 +75,58 @@ enum saa6752hs_command {
74/* ---------------------------------------------------------------------- */ 75/* ---------------------------------------------------------------------- */
75 76
76static u8 PAT[] = { 77static u8 PAT[] = {
77 0xc2, // i2c register 78 0xc2, /* i2c register */
78 0x00, // table number for encoder 79 0x00, /* table number for encoder */
79 80
80 0x47, // sync 81 0x47, /* sync */
81 0x40, 0x00, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0) 82 0x40, 0x00, /* transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid(0) */
82 0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) 83 0x10, /* transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) */
83 84
84 0x00, // PSI pointer to start of table 85 0x00, /* PSI pointer to start of table */
85 86
86 0x00, // tid(0) 87 0x00, /* tid(0) */
87 0xb0, 0x0d, // section_syntax_indicator(1), section_length(13) 88 0xb0, 0x0d, /* section_syntax_indicator(1), section_length(13) */
88 89
89 0x00, 0x01, // transport_stream_id(1) 90 0x00, 0x01, /* transport_stream_id(1) */
90 91
91 0xc1, // version_number(0), current_next_indicator(1) 92 0xc1, /* version_number(0), current_next_indicator(1) */
92 93
93 0x00, 0x00, // section_number(0), last_section_number(0) 94 0x00, 0x00, /* section_number(0), last_section_number(0) */
94 95
95 0x00, 0x01, // program_number(1) 96 0x00, 0x01, /* program_number(1) */
96 97
97 0xe0, 0x00, // PMT PID 98 0xe0, 0x00, /* PMT PID */
98 99
99 0x00, 0x00, 0x00, 0x00 // CRC32 100 0x00, 0x00, 0x00, 0x00 /* CRC32 */
100}; 101};
101 102
102static u8 PMT[] = { 103static u8 PMT[] = {
103 0xc2, // i2c register 104 0xc2, /* i2c register */
104 0x01, // table number for encoder 105 0x01, /* table number for encoder */
105 106
106 0x47, // sync 107 0x47, /* sync */
107 0x40, 0x00, // transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid 108 0x40, 0x00, /* transport_error_indicator(0), payload_unit_start(1), transport_priority(0), pid */
108 0x10, // transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) 109 0x10, /* transport_scrambling_control(00), adaptation_field_control(01), continuity_counter(0) */
109 110
110 0x00, // PSI pointer to start of table 111 0x00, /* PSI pointer to start of table */
111 112
112 0x02, // tid(2) 113 0x02, /* tid(2) */
113 0xb0, 0x17, // section_syntax_indicator(1), section_length(23) 114 0xb0, 0x17, /* section_syntax_indicator(1), section_length(23) */
114 115
115 0x00, 0x01, // program_number(1) 116 0x00, 0x01, /* program_number(1) */
116 117
117 0xc1, // version_number(0), current_next_indicator(1) 118 0xc1, /* version_number(0), current_next_indicator(1) */
118 119
119 0x00, 0x00, // section_number(0), last_section_number(0) 120 0x00, 0x00, /* section_number(0), last_section_number(0) */
120 121
121 0xe0, 0x00, // PCR_PID 122 0xe0, 0x00, /* PCR_PID */
122 123
123 0xf0, 0x00, // program_info_length(0) 124 0xf0, 0x00, /* program_info_length(0) */
124 125
125 0x02, 0xe0, 0x00, 0xf0, 0x00, // video stream type(2), pid 126 0x02, 0xe0, 0x00, 0xf0, 0x00, /* video stream type(2), pid */
126 0x04, 0xe0, 0x00, 0xf0, 0x00, // audio stream type(4), pid 127 0x04, 0xe0, 0x00, 0xf0, 0x00, /* audio stream type(4), pid */
127 128
128 0x00, 0x00, 0x00, 0x00 // CRC32 129 0x00, 0x00, 0x00, 0x00 /* CRC32 */
129}; 130};
130 131
131static struct v4l2_mpeg_compression param_defaults = 132static struct v4l2_mpeg_compression param_defaults =
@@ -166,7 +167,7 @@ static int saa6752hs_chip_command(struct i2c_client* client,
166 unsigned long timeout; 167 unsigned long timeout;
167 int status = 0; 168 int status = 0;
168 169
169 // execute the command 170 /* execute the command */
170 switch(command) { 171 switch(command) {
171 case SAA6752HS_COMMAND_RESET: 172 case SAA6752HS_COMMAND_RESET:
172 buf[0] = 0x00; 173 buf[0] = 0x00;
@@ -200,11 +201,11 @@ static int saa6752hs_chip_command(struct i2c_client* client,
200 return -EINVAL; 201 return -EINVAL;
201 } 202 }
202 203
203 // set it and wait for it to be so 204 /* set it and wait for it to be so */
204 i2c_master_send(client, buf, 1); 205 i2c_master_send(client, buf, 1);
205 timeout = jiffies + HZ * 3; 206 timeout = jiffies + HZ * 3;
206 for (;;) { 207 for (;;) {
207 // get the current status 208 /* get the current status */
208 buf[0] = 0x10; 209 buf[0] = 0x10;
209 i2c_master_send(client, buf, 1); 210 i2c_master_send(client, buf, 1);
210 i2c_master_recv(client, buf, 1); 211 i2c_master_recv(client, buf, 1);
@@ -216,14 +217,12 @@ static int saa6752hs_chip_command(struct i2c_client* client,
216 break; 217 break;
217 } 218 }
218 219
219 // wait a bit
220 msleep(10); 220 msleep(10);
221 } 221 }
222 222
223 // delay a bit to let encoder settle 223 /* delay a bit to let encoder settle */
224 msleep(50); 224 msleep(50);
225 225
226 // done
227 return status; 226 return status;
228} 227}
229 228
@@ -233,44 +232,43 @@ static int saa6752hs_set_bitrate(struct i2c_client* client,
233{ 232{
234 u8 buf[3]; 233 u8 buf[3];
235 234
236 // set the bitrate mode 235 /* set the bitrate mode */
237 buf[0] = 0x71; 236 buf[0] = 0x71;
238 buf[1] = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ? 0 : 1; 237 buf[1] = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ? 0 : 1;
239 i2c_master_send(client, buf, 2); 238 i2c_master_send(client, buf, 2);
240 239
241 // set the video bitrate 240 /* set the video bitrate */
242 if (params->vi_bitrate.mode == V4L2_BITRATE_VBR) { 241 if (params->vi_bitrate.mode == V4L2_BITRATE_VBR) {
243 // set the target bitrate 242 /* set the target bitrate */
244 buf[0] = 0x80; 243 buf[0] = 0x80;
245 buf[1] = params->vi_bitrate.target >> 8; 244 buf[1] = params->vi_bitrate.target >> 8;
246 buf[2] = params->vi_bitrate.target & 0xff; 245 buf[2] = params->vi_bitrate.target & 0xff;
247 i2c_master_send(client, buf, 3); 246 i2c_master_send(client, buf, 3);
248 247
249 // set the max bitrate 248 /* set the max bitrate */
250 buf[0] = 0x81; 249 buf[0] = 0x81;
251 buf[1] = params->vi_bitrate.max >> 8; 250 buf[1] = params->vi_bitrate.max >> 8;
252 buf[2] = params->vi_bitrate.max & 0xff; 251 buf[2] = params->vi_bitrate.max & 0xff;
253 i2c_master_send(client, buf, 3); 252 i2c_master_send(client, buf, 3);
254 } else { 253 } else {
255 // set the target bitrate (no max bitrate for CBR) 254 /* set the target bitrate (no max bitrate for CBR) */
256 buf[0] = 0x81; 255 buf[0] = 0x81;
257 buf[1] = params->vi_bitrate.target >> 8; 256 buf[1] = params->vi_bitrate.target >> 8;
258 buf[2] = params->vi_bitrate.target & 0xff; 257 buf[2] = params->vi_bitrate.target & 0xff;
259 i2c_master_send(client, buf, 3); 258 i2c_master_send(client, buf, 3);
260 } 259 }
261 260
262 // set the audio bitrate 261 /* set the audio bitrate */
263 buf[0] = 0x94; 262 buf[0] = 0x94;
264 buf[1] = (256 == params->au_bitrate.target) ? 0 : 1; 263 buf[1] = (256 == params->au_bitrate.target) ? 0 : 1;
265 i2c_master_send(client, buf, 2); 264 i2c_master_send(client, buf, 2);
266 265
267 // set the total bitrate 266 /* set the total bitrate */
268 buf[0] = 0xb1; 267 buf[0] = 0xb1;
269 buf[1] = params->st_bitrate.target >> 8; 268 buf[1] = params->st_bitrate.target >> 8;
270 buf[2] = params->st_bitrate.target & 0xff; 269 buf[2] = params->st_bitrate.target & 0xff;
271 i2c_master_send(client, buf, 3); 270 i2c_master_send(client, buf, 3);
272 271
273 // return success
274 return 0; 272 return 0;
275} 273}
276 274
@@ -376,36 +374,43 @@ static int saa6752hs_init(struct i2c_client* client)
376 374
377 h = i2c_get_clientdata(client); 375 h = i2c_get_clientdata(client);
378 376
379 // Set video format - must be done first as it resets other settings 377 /* Set video format - must be done first as it resets other settings */
380 buf[0] = 0x41; 378 buf[0] = 0x41;
381 buf[1] = h->video_format; 379 buf[1] = h->video_format;
382 i2c_master_send(client, buf, 2); 380 i2c_master_send(client, buf, 2);
383 381
384 // set bitrate 382 /* Set number of lines in input signal */
383 buf[0] = 0x40;
384 buf[1] = 0x00;
385 if (h->standard & V4L2_STD_525_60)
386 buf[1] = 0x01;
387 i2c_master_send(client, buf, 2);
388
389 /* set bitrate */
385 saa6752hs_set_bitrate(client, &h->params); 390 saa6752hs_set_bitrate(client, &h->params);
386 391
387 // Set GOP structure {3, 13} 392 /* Set GOP structure {3, 13} */
388 buf[0] = 0x72; 393 buf[0] = 0x72;
389 buf[1] = 0x03; 394 buf[1] = 0x03;
390 buf[2] = 0x0D; 395 buf[2] = 0x0D;
391 i2c_master_send(client,buf,3); 396 i2c_master_send(client,buf,3);
392 397
393 // Set minimum Q-scale {4} 398 /* Set minimum Q-scale {4} */
394 buf[0] = 0x82; 399 buf[0] = 0x82;
395 buf[1] = 0x04; 400 buf[1] = 0x04;
396 i2c_master_send(client,buf,2); 401 i2c_master_send(client,buf,2);
397 402
398 // Set maximum Q-scale {12} 403 /* Set maximum Q-scale {12} */
399 buf[0] = 0x83; 404 buf[0] = 0x83;
400 buf[1] = 0x0C; 405 buf[1] = 0x0C;
401 i2c_master_send(client,buf,2); 406 i2c_master_send(client,buf,2);
402 407
403 // Set Output Protocol 408 /* Set Output Protocol */
404 buf[0] = 0xD0; 409 buf[0] = 0xD0;
405 buf[1] = 0x81; 410 buf[1] = 0x81;
406 i2c_master_send(client,buf,2); 411 i2c_master_send(client,buf,2);
407 412
408 // Set video output stream format {TS} 413 /* Set video output stream format {TS} */
409 buf[0] = 0xB0; 414 buf[0] = 0xB0;
410 buf[1] = 0x05; 415 buf[1] = 0x05;
411 i2c_master_send(client,buf,2); 416 i2c_master_send(client,buf,2);
@@ -436,39 +441,39 @@ static int saa6752hs_init(struct i2c_client* client)
436 localPMT[sizeof(PMT) - 2] = (crc >> 8) & 0xFF; 441 localPMT[sizeof(PMT) - 2] = (crc >> 8) & 0xFF;
437 localPMT[sizeof(PMT) - 1] = crc & 0xFF; 442 localPMT[sizeof(PMT) - 1] = crc & 0xFF;
438 443
439 // Set Audio PID 444 /* Set Audio PID */
440 buf[0] = 0xC1; 445 buf[0] = 0xC1;
441 buf[1] = (h->params.ts_pid_audio >> 8) & 0xFF; 446 buf[1] = (h->params.ts_pid_audio >> 8) & 0xFF;
442 buf[2] = h->params.ts_pid_audio & 0xFF; 447 buf[2] = h->params.ts_pid_audio & 0xFF;
443 i2c_master_send(client,buf,3); 448 i2c_master_send(client,buf,3);
444 449
445 // Set Video PID 450 /* Set Video PID */
446 buf[0] = 0xC0; 451 buf[0] = 0xC0;
447 buf[1] = (h->params.ts_pid_video >> 8) & 0xFF; 452 buf[1] = (h->params.ts_pid_video >> 8) & 0xFF;
448 buf[2] = h->params.ts_pid_video & 0xFF; 453 buf[2] = h->params.ts_pid_video & 0xFF;
449 i2c_master_send(client,buf,3); 454 i2c_master_send(client,buf,3);
450 455
451 // Set PCR PID 456 /* Set PCR PID */
452 buf[0] = 0xC4; 457 buf[0] = 0xC4;
453 buf[1] = (h->params.ts_pid_pcr >> 8) & 0xFF; 458 buf[1] = (h->params.ts_pid_pcr >> 8) & 0xFF;
454 buf[2] = h->params.ts_pid_pcr & 0xFF; 459 buf[2] = h->params.ts_pid_pcr & 0xFF;
455 i2c_master_send(client,buf,3); 460 i2c_master_send(client,buf,3);
456 461
457 // Send SI tables 462 /* Send SI tables */
458 i2c_master_send(client,localPAT,sizeof(PAT)); 463 i2c_master_send(client,localPAT,sizeof(PAT));
459 i2c_master_send(client,localPMT,sizeof(PMT)); 464 i2c_master_send(client,localPMT,sizeof(PMT));
460 465
461 // mute then unmute audio. This removes buzzing artefacts 466 /* mute then unmute audio. This removes buzzing artefacts */
462 buf[0] = 0xa4; 467 buf[0] = 0xa4;
463 buf[1] = 1; 468 buf[1] = 1;
464 i2c_master_send(client, buf, 2); 469 i2c_master_send(client, buf, 2);
465 buf[1] = 0; 470 buf[1] = 0;
466 i2c_master_send(client, buf, 2); 471 i2c_master_send(client, buf, 2);
467 472
468 // start it going 473 /* start it going */
469 saa6752hs_chip_command(client, SAA6752HS_COMMAND_START); 474 saa6752hs_chip_command(client, SAA6752HS_COMMAND_START);
470 475
471 // readout current state 476 /* readout current state */
472 buf[0] = 0xE1; 477 buf[0] = 0xE1;
473 buf[1] = 0xA7; 478 buf[1] = 0xA7;
474 buf[2] = 0xFE; 479 buf[2] = 0xFE;
@@ -477,7 +482,7 @@ static int saa6752hs_init(struct i2c_client* client)
477 i2c_master_send(client, buf, 5); 482 i2c_master_send(client, buf, 5);
478 i2c_master_recv(client, buf2, 4); 483 i2c_master_recv(client, buf2, 4);
479 484
480 // change aspect ratio 485 /* change aspect ratio */
481 buf[0] = 0xE0; 486 buf[0] = 0xE0;
482 buf[1] = 0xA7; 487 buf[1] = 0xA7;
483 buf[2] = 0xFE; 488 buf[2] = 0xFE;
@@ -498,7 +503,6 @@ static int saa6752hs_init(struct i2c_client* client)
498 buf[8] = buf2[3]; 503 buf[8] = buf2[3];
499 i2c_master_send(client, buf, 9); 504 i2c_master_send(client, buf, 9);
500 505
501 // return success
502 return 0; 506 return 0;
503} 507}
504 508
@@ -516,6 +520,9 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
516 h->client.adapter = adap; 520 h->client.adapter = adap;
517 h->client.addr = addr; 521 h->client.addr = addr;
518 522
523 /* Assume 625 input lines */
524 h->standard = 0;
525
519 i2c_set_clientdata(&h->client, h); 526 i2c_set_clientdata(&h->client, h);
520 i2c_attach_client(&h->client); 527 i2c_attach_client(&h->client);
521 return 0; 528 return 0;
@@ -576,6 +583,9 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
576 saa6752hs_set_subsampling(client, f); 583 saa6752hs_set_subsampling(client, f);
577 break; 584 break;
578 } 585 }
586 case VIDIOC_S_STD:
587 h->standard = *((v4l2_std_id *) arg);
588 break;
579 default: 589 default:
580 /* nothing */ 590 /* nothing */
581 break; 591 break;