Lines Matching +full:codec +full:- +full:3

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)
44 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);
57 struct zoran *zr = videocodec_to_zoran(ptr->codec);
62 if (ptr->codec->master_data->writereg)
63 ptr->codec->master_data->writereg(ptr->codec, reg, value);
65 zrdev_err(zr, "%s: invalid I/O setup, nothing written!\n", ptr->name);
77 ptr->status = zr36060_read(ptr, ZR060_CFSR);
80 return ptr->status;
86 ptr->scalefact = (zr36060_read(ptr, ZR060_SF_HI) << 8) |
91 return ptr->scalefact;
94 /* wait if codec is ready to proceed (end of processing) or time is over */
97 struct zoran *zr = videocodec_to_zoran(ptr->codec);
105 ptr->name, ptr->status);
114 struct zoran *zr = videocodec_to_zoran(ptr->codec);
118 zrdev_err(zr, "%s: attach failed, can't connect to jpeg processor!\n", ptr->name);
119 return -ENXIO;
123 if (ptr->status & ZR060_CFSR_BUSY) {
124 zrdev_err(zr, "%s: attach failed, jpeg processor failed (end flag)!\n", ptr->name);
125 return -EBUSY;
134 struct zoran *zr = videocodec_to_zoran(ptr->codec);
137 zrdev_dbg(zr, "%s: write data block to 0x%04x (len=%d)\n", ptr->name,
252 struct zoran *zr = videocodec_to_zoran(ptr->codec);
256 zrdev_dbg(zr, "%s: write SOF (%dx%d, %d components)\n", ptr->name,
257 ptr->width, ptr->height, NO_OF_COMPONENTS);
261 sof_data[3] = (3 * NO_OF_COMPONENTS) + 8;
263 sof_data[5] = (ptr->height) >> 8;
264 sof_data[6] = (ptr->height) & 0xff;
265 sof_data[7] = (ptr->width) >> 8;
266 sof_data[8] = (ptr->width) & 0xff;
269 sof_data[10 + (i * 3)] = i; // index identifier
270 sof_data[11 + (i * 3)] = (ptr->h_samp_ratio[i] << 4) |
271 (ptr->v_samp_ratio[i]); // sampling ratios
272 sof_data[12 + (i * 3)] = zr36060_tq[i]; // Q table selection
275 (3 * NO_OF_COMPONENTS) + 10, sof_data);
281 struct zoran *zr = videocodec_to_zoran(ptr->codec);
285 zrdev_dbg(zr, "%s: write SOS\n", ptr->name);
289 sos_data[3] = 2 + 1 + (2 * NO_OF_COMPONENTS) + 3;
297 sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 3] = 0x3f;
300 4 + 1 + (2 * NO_OF_COMPONENTS) + 3,
307 struct zoran *zr = videocodec_to_zoran(ptr->codec);
310 zrdev_dbg(zr, "%s: write DRI\n", ptr->name);
314 dri_data[3] = 0x04;
315 dri_data[4] = (ptr->dri) >> 8;
316 dri_data[5] = (ptr->dri) & 0xff;
327 struct zoran *zr = videocodec_to_zoran(ptr->codec);
329 if (ptr->mode == CODEC_DO_COMPRESSION) {
330 zrdev_dbg(zr, "%s: COMPRESSION SETUP\n", ptr->name);
338 /*FIXME: What about ptr->bitrate_ctrl? */
346 /* Disable all IRQs - no DataErr means autoreset */
350 zr36060_write(ptr, ZR060_SF_HI, ptr->scalefact >> 8);
351 zr36060_write(ptr, ZR060_SF_LO, ptr->scalefact & 0xff);
362 /* setup the fixed jpeg tables - maybe variable, though - (see table init section above) */
366 zr36060_write(ptr, ZR060_APP_IDX + 1, 0xe0 + ptr->app.appn);
368 zr36060_write(ptr, ZR060_APP_IDX + 3, ptr->app.len + 2);
369 sum += zr36060_pushit(ptr, ZR060_APP_IDX + 4, 60, ptr->app.data) + 4;
373 zr36060_write(ptr, ZR060_COM_IDX + 3, ptr->com.len + 2);
374 sum += zr36060_pushit(ptr, ZR060_COM_IDX + 4, 60, ptr->com.data) + 4;
379 sum = ptr->real_code_vol - sum;
380 bitcnt = sum << 3; /* need the size in bits */
385 ptr->name, sum, ptr->real_code_vol, bitcnt, tmp);
392 bitcnt -= bitcnt >> 7; // bits without stuffing
393 bitcnt -= ((bitcnt * 5) >> 6); // bits without eob
397 ptr->name, bitcnt, tmp);
407 ((ptr->com.len > 0) ? ZR060_MER_COM : 0) |
408 ((ptr->app.len > 0) ? ZR060_MER_APP : 0));
411 /* Limit pixel range to 16..235 as per CCIR-601 */
415 zrdev_dbg(zr, "%s: EXPANSION SETUP\n", ptr->name);
430 /* Disable all IRQs - no DataErr means autoreset */
436 /* setup the fixed jpeg tables - maybe variable, though - (see table init section above) */
449 ptr->name, ptr->status);
451 if (ptr->status & ZR060_CFSR_BUSY) {
452 zrdev_err(zr, "%s: init aborted!\n", ptr->name);
458 * CODEC API FUNCTIONS
463 /* set compressiion/expansion mode and launches codec -
466 static int zr36060_set_mode(struct videocodec *codec, int mode)
468 struct zr36060 *ptr = (struct zr36060 *)codec->data;
469 struct zoran *zr = videocodec_to_zoran(codec);
471 zrdev_dbg(zr, "%s: set_mode %d call\n", ptr->name, mode);
474 return -EINVAL;
476 ptr->mode = mode;
482 /* set picture size (norm is ignored as the codec doesn't know about it) */
483 static int zr36060_set_video(struct videocodec *codec, const struct tvnorm *norm,
486 struct zr36060 *ptr = (struct zr36060 *)codec->data;
487 struct zoran *zr = videocodec_to_zoran(codec);
491 zrdev_dbg(zr, "%s: set_video (%u,%u)/%ux%u (%%%d) call\n", ptr->name,
492 cap->x, cap->y, cap->width, cap->height, cap->decimation);
494 /* if () return -EINVAL;
495 * trust the master driver that it knows what it does - so
498 ptr->width = cap->width / (cap->decimation & 0xff);
499 ptr->height = cap->height / (cap->decimation >> 8);
506 * left unchanged here - in accordance with datasheet).
508 reg = (!pol->vsync_pol ? ZR060_VPR_VS_POL : 0)
509 | (!pol->hsync_pol ? ZR060_VPR_HS_POL : 0)
510 | (pol->field_pol ? ZR060_VPR_FI_POL : 0)
511 | (pol->blank_pol ? ZR060_VPR_BL_POL : 0)
512 | (pol->subimg_pol ? ZR060_VPR_S_IMG_POL : 0)
513 | (pol->poe_pol ? ZR060_VPR_POE_POL : 0)
514 | (pol->pvalid_pol ? ZR060_VPR_P_VAL_POL : 0)
515 | (pol->vclk_pol ? ZR060_VPR_VCLK_POL : 0);
519 switch (cap->decimation & 0xff) {
533 switch (cap->decimation >> 8) {
550 reg = norm->ht - 1; /* Vtotal */
554 reg = norm->wt - 1; /* Htotal */
558 reg = 6 - 1; /* VsyncSize */
564 reg = norm->v_start - 1; /* BVstart */
567 reg += norm->ha / 2; /* BVend */
571 reg = norm->h_start - 1; /* BHstart */
574 reg += norm->wa; /* BHend */
579 reg = cap->y + norm->v_start; /* Vstart */
583 reg += cap->height; /* Vend */
587 reg = cap->x + norm->h_start; /* Hstart */
591 reg += cap->width; /* Hend */
596 reg = norm->v_start - 4; /* SVstart */
600 reg += norm->ha / 2 + 8; /* SVend */
604 reg = norm->h_start /*+ 64 */ - 4; /* SHstart */
608 reg += norm->wa + 8; /* SHend */
612 size = ptr->width * ptr->height;
621 size = size * cap->quality / (low_bitrate ? 400 : 200);
626 if (size > ptr->total_code_vol * 7)
627 size = ptr->total_code_vol * 7;
629 ptr->real_code_vol = size >> 3; /* in bytes */
635 reg = ptr->max_block_vol;
642 static int zr36060_control(struct videocodec *codec, int type, int size, void *data)
644 struct zr36060 *ptr = (struct zr36060 *)codec->data;
645 struct zoran *zr = videocodec_to_zoran(codec);
648 zrdev_dbg(zr, "%s: control %d call with %d byte\n", ptr->name, type,
654 return -EFAULT;
656 *ival = ptr->status;
661 return -EFAULT;
667 return -EFAULT;
669 return -EINVAL;
680 return -ENXIO;
684 return -EFAULT;
685 *ival = ptr->total_code_vol;
690 return -EFAULT;
691 ptr->total_code_vol = *ival;
692 ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3;
697 return -EFAULT;
703 return -EFAULT;
704 ptr->scalefact = *ival;
711 return -EFAULT;
713 *app = ptr->app;
721 return -EFAULT;
723 ptr->app = *app;
731 return -EFAULT;
733 *com = ptr->com;
741 return -EFAULT;
743 ptr->com = *com;
748 return -EINVAL;
759 static int zr36060_unset(struct videocodec *codec)
761 struct zr36060 *ptr = codec->data;
762 struct zoran *zr = videocodec_to_zoran(codec);
765 /* do wee need some codec deinit here, too ???? */
767 zrdev_dbg(zr, "%s: finished codec #%d\n", ptr->name, ptr->num);
769 codec->data = NULL;
771 zr36060_codecs--;
775 return -EFAULT;
785 static int zr36060_setup(struct videocodec *codec)
788 struct zoran *zr = videocodec_to_zoran(codec);
796 return -ENOSPC;
800 codec->data = ptr;
802 return -ENOMEM;
804 snprintf(ptr->name, sizeof(ptr->name), "zr36060[%d]", zr36060_codecs);
805 ptr->num = zr36060_codecs++;
806 ptr->codec = codec;
811 zr36060_unset(codec);
815 memcpy(ptr->h_samp_ratio, zr36060_decimation_h, 8);
816 memcpy(ptr->v_samp_ratio, zr36060_decimation_v, 8);
818 ptr->bitrate_ctrl = 0; /* 0 or 1 - fixed file size flag (what is the difference?) */
819 ptr->mode = CODEC_DO_COMPRESSION;
820 ptr->width = 384;
821 ptr->height = 288;
822 ptr->total_code_vol = 16000; /* CHECKME */
823 ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3;
824 ptr->max_block_vol = 240; /* CHECKME, was 120 is 240 */
825 ptr->scalefact = 0x100;
826 ptr->dri = 1; /* CHECKME, was 8 is 1 */
828 /* by default, no COM or APP markers - app should set those */
829 ptr->com.len = 0;
830 ptr->app.appn = 0;
831 ptr->app.len = 0;
835 zrdev_info(zr, "%s: codec attached and running\n", ptr->name);
864 pr_debug("zr36060: something's wrong - %d codecs left somehow.\n",