/* just in case something is wrong... */ if (ptr->codec->master_data->readreg)
value = (ptr->codec->master_data->readreg(ptr->codec, reg)) & 0xFF; else
zrdev_err(zr, "%s: invalid I/O setup, nothing read!\n", ptr->name);
zrdev_dbg(zr, "%s: reading from 0x%04x: %02x\n", ptr->name, reg, value);
zrdev_dbg(zr, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value, reg);
/* just in case something is wrong... */ if (ptr->codec->master_data->writereg)
ptr->codec->master_data->writereg(ptr->codec, reg, value); else
zrdev_err(zr, "%s: invalid I/O setup, nothing written!\n",
ptr->name);
}
/* status is kept in datastructure */ static u8 zr36050_read_status1(struct zr36050 *ptr)
{
ptr->status1 = zr36050_read(ptr, ZR050_STATUS_1);
/* Local helper function: simple loop for pushing the init datasets */
staticint zr36050_pushit(struct zr36050 *ptr, u16 startreg, u16 len, constchar *data)
{ struct zoran *zr = videocodec_to_zoran(ptr->codec); int i = 0;
zrdev_dbg(zr, "%s: write data block to 0x%04x (len=%d)\n", ptr->name,
startreg, len); while (i < len)
zr36050_write(ptr, startreg++, data[i++]);
return i;
}
/* * Basic datasets: * * jpeg baseline setup data (you find it on lots places in internet, or just * extract it from any regular .jpg image...) * * Could be variable, but until it's not needed it they are just fixed to save * memory. Otherwise expand zr36050 structure with arrays, push the values to * it and initialize from there, as e.g. the linux zr36057/60 driver does it.
*/
/* * SOF (start of frame) segment depends on width, height and sampling ratio * of each color component
*/ staticint zr36050_set_sof(struct zr36050 *ptr)
{ struct zoran *zr = videocodec_to_zoran(ptr->codec); char sof_data[34]; // max. size of register set int i;
/* compression setup with or without bitrate control */
zr36050_write(ptr, ZR050_MODE,
ZR050_MO_COMP | ZR050_MO_PASS2 |
(ptr->bitrate_ctrl ? ZR050_MO_BRC : 0));
/* do the internal huffman table preload */
zr36050_write(ptr, ZR050_MARKERS_EN, ZR050_ME_DHTI);
zr36050_write(ptr, ZR050_GO, 1); // launch codec
zr36050_wait_end(ptr);
zrdev_dbg(zr, "%s: Status after table preload: 0x%02x\n",
ptr->name, ptr->status1);
if ((ptr->status1 & 0x4) == 0) {
zrdev_err(zr, "%s: init aborted!\n", ptr->name); return; // something is wrong, its timed out!!!!
}
/* setup misc. data for expansion */
zr36050_write(ptr, ZR050_MODE, 0);
zr36050_write(ptr, ZR050_MARKERS_EN, 0);
}
/* adr on selected, to allow GO from master */
zr36050_read(ptr, 0);
}
/* * CODEC API FUNCTIONS * * this functions are accessed by the master via the API structure
*/
/* * set compression/expansion mode and launches codec - * this should be the last call from the master before starting processing
*/ staticint zr36050_set_mode(struct videocodec *codec, int mode)
{ struct zr36050 *ptr = (struct zr36050 *)codec->data; struct zoran *zr = videocodec_to_zoran(codec);
/* Minimum: 1kb */ if (size < 8192)
size = 8192; /* Maximum: 7/8 of code buffer */ if (size > ptr->total_code_vol * 7)
size = ptr->total_code_vol * 7;
ptr->real_code_vol = size >> 3; /* in bytes */
/* * Set max_block_vol here (previously in zr36050_init, moved * here for consistency with zr36060 code
*/
zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol);
return 0;
}
/* additional control functions */ staticint zr36050_control(struct videocodec *codec, int type, int size, void *data)
{ struct zr36050 *ptr = (struct zr36050 *)codec->data; struct zoran *zr = videocodec_to_zoran(codec); int *ival = (int *)data;
zrdev_dbg(zr, "%s: control %d call with %d byte\n", ptr->name, type,
size);
switch (type) { case CODEC_G_STATUS: /* get last status */ if (size != sizeof(int)) return -EFAULT;
zr36050_read_status1(ptr);
*ival = ptr->status1; break;
case CODEC_G_CODEC_MODE: if (size != sizeof(int)) return -EFAULT;
*ival = CODEC_MODE_BJPG; break;
case CODEC_S_CODEC_MODE: if (size != sizeof(int)) return -EFAULT; if (*ival != CODEC_MODE_BJPG) return -EINVAL; /* not needed, do nothing */ return 0;
case CODEC_G_VFE: case CODEC_S_VFE: /* not needed, do nothing */ return 0;
case CODEC_S_MMAP: /* not available, give an error */ return -ENXIO;
case CODEC_G_JPEG_TDS_BYTE: /* get target volume in byte */ if (size != sizeof(int)) return -EFAULT;
*ival = ptr->total_code_vol; break;
case CODEC_S_JPEG_TDS_BYTE: /* get target volume in byte */ if (size != sizeof(int)) return -EFAULT;
ptr->total_code_vol = *ival;
ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3; break;
case CODEC_G_JPEG_SCALE: /* get scaling factor */ if (size != sizeof(int)) return -EFAULT;
*ival = zr36050_read_scalefactor(ptr); break;
case CODEC_S_JPEG_SCALE: /* set scaling factor */ if (size != sizeof(int)) return -EFAULT;
ptr->scalefact = *ival; break;
case CODEC_G_JPEG_APP_DATA: { /* get appn marker data */ struct jpeg_app_marker *app = data;
if (size != sizeof(struct jpeg_app_marker)) return -EFAULT;
*app = ptr->app; break;
}
case CODEC_S_JPEG_APP_DATA: { /* set appn marker data */ struct jpeg_app_marker *app = data;
if (size != sizeof(struct jpeg_app_marker)) return -EFAULT;
ptr->app = *app; break;
}
case CODEC_G_JPEG_COM_DATA: { /* get comment marker data */ struct jpeg_com_marker *com = data;
if (size != sizeof(struct jpeg_com_marker)) return -EFAULT;
*com = ptr->com; break;
}
case CODEC_S_JPEG_COM_DATA: { /* set comment marker data */ struct jpeg_com_marker *com = data;
if (size != sizeof(struct jpeg_com_marker)) return -EFAULT;
ptr->com = *com; break;
}
default: return -EINVAL;
}
return size;
}
/* Exit and unregister function: Deinitializes Zoran's JPEG processor */
/* * Setup and registry function: * * Initializes Zoran's JPEG processor * * Also sets pixel size, average code size, mode (compr./decompr.) * (the given size is determined by the processor with the video interface)
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.