Lines Matching +full:codec +full:- +full:2

1 // SPDX-License-Identifier: GPL-2.0-or-later
22 /* codec io API */
37 * read/write via codec layer (registers are located in the master device)
43 struct zoran *zr = videocodec_to_zoran(ptr->codec);
47 if (ptr->codec->master_data->readreg)
48 value = (ptr->codec->master_data->readreg(ptr->codec, reg)) & 0xFF;
50 zrdev_err(zr, "%s: invalid I/O setup, nothing read!\n", ptr->name);
52 zrdev_dbg(zr, "%s: reading from 0x%04x: %02x\n", ptr->name, reg, value);
59 struct zoran *zr = videocodec_to_zoran(ptr->codec);
61 zrdev_dbg(zr, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value, reg);
64 if (ptr->codec->master_data->writereg)
65 ptr->codec->master_data->writereg(ptr->codec, reg, value);
68 ptr->name);
74 ptr->status1 = zr36050_read(ptr, ZR050_STATUS_1);
77 return ptr->status1;
83 ptr->scalefact = (zr36050_read(ptr, ZR050_SF_HI) << 8) |
88 return ptr->scalefact;
94 * wait if codec is ready to proceed (end of processing) or time is over
99 struct zoran *zr = videocodec_to_zoran(ptr->codec);
107 ptr->name, ptr->status1);
120 struct zoran *zr = videocodec_to_zoran(ptr->codec);
128 ptr->name);
129 return -ENXIO;
137 ptr->name);
138 return -ENXIO;
142 if ((ptr->status1 & 0x4) == 0) {
145 ptr->name);
146 return -EBUSY;
156 struct zoran *zr = videocodec_to_zoran(ptr->codec);
159 zrdev_dbg(zr, "%s: write data block to 0x%04x (len=%d)\n", ptr->name,
180 0x00, 0x84, //Length: 2*65+2
203 0x01, 0xa2, //Length: 2*AC, 2*DC
266 static const char zr36050_decimation_h[8] = { 2, 1, 1, 0, 0, 0, 0, 0 };
272 * calculation and setup of parameter-dependent JPEG baseline segments
276 /* ------------------------------------------------------------------------- */
284 struct zoran *zr = videocodec_to_zoran(ptr->codec);
288 zrdev_dbg(zr, "%s: write SOF (%dx%d, %d components)\n", ptr->name,
289 ptr->width, ptr->height, NO_OF_COMPONENTS);
292 sof_data[2] = 0x00;
295 sof_data[5] = (ptr->height) >> 8;
296 sof_data[6] = (ptr->height) & 0xff;
297 sof_data[7] = (ptr->width) >> 8;
298 sof_data[8] = (ptr->width) & 0xff;
302 sof_data[11 + (i * 3)] = (ptr->h_samp_ratio[i] << 4) |
303 (ptr->v_samp_ratio[i]); // sampling ratios
310 /* ------------------------------------------------------------------------- */
319 struct zoran *zr = videocodec_to_zoran(ptr->codec);
323 zrdev_dbg(zr, "%s: write SOS\n", ptr->name);
326 sos_data[2] = 0x00;
327 sos_data[3] = 2 + 1 + (2 * NO_OF_COMPONENTS) + 3;
330 sos_data[5 + (i * 2)] = i; // index
331 sos_data[6 + (i * 2)] = (zr36050_td[i] << 4) | zr36050_ta[i]; // AC/DC tbl.sel.
333 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 2] = 00; // scan start
334 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 3] = 0x3F;
335 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 4] = 00;
337 4 + 1 + (2 * NO_OF_COMPONENTS) + 3,
341 /* ------------------------------------------------------------------------- */
347 struct zoran *zr = videocodec_to_zoran(ptr->codec);
350 zrdev_dbg(zr, "%s: write DRI\n", ptr->name);
353 dri_data[2] = 0x00;
355 dri_data[4] = ptr->dri >> 8;
356 dri_data[5] = ptr->dri & 0xff;
372 struct zoran *zr = videocodec_to_zoran(ptr->codec);
374 if (ptr->mode == CODEC_DO_COMPRESSION) {
375 zrdev_dbg(zr, "%s: COMPRESSION SETUP\n", ptr->name);
387 zr36050_write(ptr, ZR050_INT_REQ_1, 3); // low 2 bits always 1
390 /*zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol);*/
391 zr36050_write(ptr, ZR050_SF_HI, ptr->scalefact >> 8);
392 zr36050_write(ptr, ZR050_SF_LO, ptr->scalefact & 0xff);
404 * setup the fixed jpeg tables - maybe variable, though -
407 zrdev_dbg(zr, "%s: write DQT, DHT, APP\n", ptr->name);
413 zr36050_write(ptr, ZR050_APP_IDX + 1, 0xe0 + ptr->app.appn);
414 zr36050_write(ptr, ZR050_APP_IDX + 2, 0x00);
415 zr36050_write(ptr, ZR050_APP_IDX + 3, ptr->app.len + 2);
417 ptr->app.data) + 4;
420 zr36050_write(ptr, ZR050_COM_IDX + 2, 0x00);
421 zr36050_write(ptr, ZR050_COM_IDX + 3, ptr->com.len + 2);
423 ptr->com.data) + 4;
428 zr36050_write(ptr, ZR050_GO, 1); // launch codec
431 ptr->name, ptr->status1);
433 if ((ptr->status1 & 0x4) == 0) {
434 zrdev_err(zr, "%s: init aborted!\n", ptr->name);
441 sum = ptr->real_code_vol - sum;
447 ptr->name, sum, ptr->real_code_vol, bitcnt, tmp);
454 bitcnt -= bitcnt >> 7; // bits without stuffing
455 bitcnt -= ((bitcnt * 5) >> 6); // bits without eob
459 ptr->name, bitcnt, tmp);
469 (ptr->bitrate_ctrl ? ZR050_MO_BRC : 0));
474 ((ptr->app.len > 0) ? ZR050_ME_APP : 0) |
475 ((ptr->com.len > 0) ? ZR050_ME_COM : 0));
477 zrdev_dbg(zr, "%s: EXPANSION SETUP\n", ptr->name);
488 zr36050_write(ptr, ZR050_INT_REQ_1, 3); // low 2 bits always 1
490 zrdev_dbg(zr, "%s: write DHT\n", ptr->name);
497 zr36050_write(ptr, ZR050_GO, 1); // launch codec
500 ptr->name, ptr->status1);
502 if ((ptr->status1 & 0x4) == 0) {
503 zrdev_err(zr, "%s: init aborted!\n", ptr->name);
517 * CODEC API FUNCTIONS
523 * set compression/expansion mode and launches codec -
526 static int zr36050_set_mode(struct videocodec *codec, int mode)
528 struct zr36050 *ptr = (struct zr36050 *)codec->data;
529 struct zoran *zr = videocodec_to_zoran(codec);
531 zrdev_dbg(zr, "%s: set_mode %d call\n", ptr->name, mode);
534 return -EINVAL;
536 ptr->mode = mode;
542 /* set picture size (norm is ignored as the codec doesn't know about it) */
543 static int zr36050_set_video(struct videocodec *codec, const struct tvnorm *norm,
546 struct zr36050 *ptr = (struct zr36050 *)codec->data;
547 struct zoran *zr = videocodec_to_zoran(codec);
551 ptr->name, norm->h_start, norm->v_start,
552 cap->x, cap->y, cap->width, cap->height,
553 cap->decimation, cap->quality);
555 * trust the master driver that it knows what it does - so
558 ptr->width = cap->width / (cap->decimation & 0xff);
559 ptr->height = cap->height / ((cap->decimation >> 8) & 0xff);
562 size = ptr->width * ptr->height;
565 size = size * cap->quality / 200;
571 if (size > ptr->total_code_vol * 7)
572 size = ptr->total_code_vol * 7;
574 ptr->real_code_vol = size >> 3; /* in bytes */
580 zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol);
586 static int zr36050_control(struct videocodec *codec, int type, int size, void *data)
588 struct zr36050 *ptr = (struct zr36050 *)codec->data;
589 struct zoran *zr = videocodec_to_zoran(codec);
592 zrdev_dbg(zr, "%s: control %d call with %d byte\n", ptr->name, type,
598 return -EFAULT;
600 *ival = ptr->status1;
605 return -EFAULT;
611 return -EFAULT;
613 return -EINVAL;
624 return -ENXIO;
628 return -EFAULT;
629 *ival = ptr->total_code_vol;
634 return -EFAULT;
635 ptr->total_code_vol = *ival;
636 ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3;
641 return -EFAULT;
647 return -EFAULT;
648 ptr->scalefact = *ival;
655 return -EFAULT;
657 *app = ptr->app;
665 return -EFAULT;
667 ptr->app = *app;
675 return -EFAULT;
677 *com = ptr->com;
685 return -EFAULT;
687 ptr->com = *com;
692 return -EINVAL;
700 static int zr36050_unset(struct videocodec *codec)
702 struct zr36050 *ptr = codec->data;
703 struct zoran *zr = videocodec_to_zoran(codec);
706 /* do wee need some codec deinit here, too ???? */
708 zrdev_dbg(zr, "%s: finished codec #%d\n", ptr->name,
709 ptr->num);
711 codec->data = NULL;
713 zr36050_codecs--;
717 return -EFAULT;
729 static int zr36050_setup(struct videocodec *codec)
732 struct zoran *zr = videocodec_to_zoran(codec);
741 return -ENOSPC;
745 codec->data = ptr;
747 return -ENOMEM;
749 snprintf(ptr->name, sizeof(ptr->name), "zr36050[%d]",
751 ptr->num = zr36050_codecs++;
752 ptr->codec = codec;
757 zr36050_unset(codec);
761 memcpy(ptr->h_samp_ratio, zr36050_decimation_h, 8);
762 memcpy(ptr->v_samp_ratio, zr36050_decimation_v, 8);
764 /* 0 or 1 - fixed file size flag (what is the difference?) */
765 ptr->bitrate_ctrl = 0;
766 ptr->mode = CODEC_DO_COMPRESSION;
767 ptr->width = 384;
768 ptr->height = 288;
769 ptr->total_code_vol = 16000;
770 ptr->max_block_vol = 240;
771 ptr->scalefact = 0x100;
772 ptr->dri = 1;
775 ptr->app.appn = 0;
776 ptr->app.len = 0;
777 ptr->com.len = 0;
781 zrdev_info(zr, "%s: codec attached and running\n",
782 ptr->name);
813 pr_debug("zr36050: something's wrong - %d codecs left somehow.\n",