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