コード例 #1
0
ファイル: zr36050.c プロジェクト: robacklin/ts7800
static int
zr36050_set_sof (struct zr36050 *ptr)
{
	char sof_data[34];	// max. size of register set
	int i;

	dprintk(3, "%s: write SOF (%dx%d, %d components)\n", ptr->name,
		ptr->width, ptr->height, NO_OF_COMPONENTS);
	sof_data[0] = 0xff;
	sof_data[1] = 0xc0;
	sof_data[2] = 0x00;
	sof_data[3] = (3 * NO_OF_COMPONENTS) + 8;
	sof_data[4] = BASELINE_PRECISION;	// only '8' possible with zr36050
	sof_data[5] = (ptr->height) >> 8;
	sof_data[6] = (ptr->height) & 0xff;
	sof_data[7] = (ptr->width) >> 8;
	sof_data[8] = (ptr->width) & 0xff;
	sof_data[9] = NO_OF_COMPONENTS;
	for (i = 0; i < NO_OF_COMPONENTS; i++) {
		sof_data[10 + (i * 3)] = i;	// index identifier
		sof_data[11 + (i * 3)] = (ptr->h_samp_ratio[i] << 4) | (ptr->v_samp_ratio[i]);	// sampling ratios
		sof_data[12 + (i * 3)] = zr36050_tq[i];	// Q table selection
	}
	return zr36050_pushit(ptr, ZR050_SOF_IDX,
			      (3 * NO_OF_COMPONENTS) + 10, sof_data);
}
コード例 #2
0
ファイル: zr36050.c プロジェクト: robacklin/ts7800
static int
zr36050_set_dri (struct zr36050 *ptr)
{
	char dri_data[6];	// max. size of register set

	dprintk(3, "%s: write DRI\n", ptr->name);
	dri_data[0] = 0xff;
	dri_data[1] = 0xdd;
	dri_data[2] = 0x00;
	dri_data[3] = 0x04;
	dri_data[4] = ptr->dri >> 8;
	dri_data[5] = ptr->dri & 0xff;
	return zr36050_pushit(ptr, ZR050_DRI_IDX, 6, dri_data);
}
コード例 #3
0
ファイル: zr36050.c プロジェクト: robacklin/ts7800
static int
zr36050_set_sos (struct zr36050 *ptr)
{
	char sos_data[16];	// max. size of register set
	int i;

	dprintk(3, "%s: write SOS\n", ptr->name);
	sos_data[0] = 0xff;
	sos_data[1] = 0xda;
	sos_data[2] = 0x00;
	sos_data[3] = 2 + 1 + (2 * NO_OF_COMPONENTS) + 3;
	sos_data[4] = NO_OF_COMPONENTS;
	for (i = 0; i < NO_OF_COMPONENTS; i++) {
		sos_data[5 + (i * 2)] = i;	// index
		sos_data[6 + (i * 2)] = (zr36050_td[i] << 4) | zr36050_ta[i];	// AC/DC tbl.sel.
	}
	sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 2] = 00;	// scan start
	sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 3] = 0x3F;
	sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 4] = 00;
	return zr36050_pushit(ptr, ZR050_SOS1_IDX,
			      4 + 1 + (2 * NO_OF_COMPONENTS) + 3,
			      sos_data);
}
コード例 #4
0
ファイル: zr36050.c プロジェクト: robacklin/ts7800
/* =========================================================================
   Setup function:

   Setup compression/decompression of Zoran's JPEG processor
   ( see also zoran 36050 manual )

   ... sorry for the spaghetti code ...
   ========================================================================= */
static void
zr36050_init (struct zr36050 *ptr)
{
	int sum = 0;
	long bitcnt, tmp;

	if (ptr->mode == CODEC_DO_COMPRESSION) {
		dprintk(2, "%s: COMPRESSION SETUP\n", ptr->name);

		/* 050 communicates with 057 in master mode */
		zr36050_write(ptr, ZR050_HARDWARE, ZR050_HW_MSTR);

		/* encoding table preload for compression */
		zr36050_write(ptr, ZR050_MODE,
			      ZR050_MO_COMP | ZR050_MO_TLM);
		zr36050_write(ptr, ZR050_OPTIONS, 0);

		/* disable all IRQs */
		zr36050_write(ptr, ZR050_INT_REQ_0, 0);
		zr36050_write(ptr, ZR050_INT_REQ_1, 3);	// low 2 bits always 1

		/* volume control settings */
		/*zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol);*/
		zr36050_write(ptr, ZR050_SF_HI, ptr->scalefact >> 8);
		zr36050_write(ptr, ZR050_SF_LO, ptr->scalefact & 0xff);

		zr36050_write(ptr, ZR050_AF_HI, 0xff);
		zr36050_write(ptr, ZR050_AF_M, 0xff);
		zr36050_write(ptr, ZR050_AF_LO, 0xff);

		/* setup the variable jpeg tables */
		sum += zr36050_set_sof(ptr);
		sum += zr36050_set_sos(ptr);
		sum += zr36050_set_dri(ptr);

		/* setup the fixed jpeg tables - maybe variable, though -
		 * (see table init section above) */
		dprintk(3, "%s: write DQT, DHT, APP\n", ptr->name);
		sum += zr36050_pushit(ptr, ZR050_DQT_IDX,
				      sizeof(zr36050_dqt), zr36050_dqt);
		sum += zr36050_pushit(ptr, ZR050_DHT_IDX,
				      sizeof(zr36050_dht), zr36050_dht);
		zr36050_write(ptr, ZR050_APP_IDX, 0xff);
		zr36050_write(ptr, ZR050_APP_IDX + 1, 0xe0 + ptr->app.appn);
		zr36050_write(ptr, ZR050_APP_IDX + 2, 0x00);
		zr36050_write(ptr, ZR050_APP_IDX + 3, ptr->app.len + 2);
		sum += zr36050_pushit(ptr, ZR050_APP_IDX + 4, 60,
				      ptr->app.data) + 4;
		zr36050_write(ptr, ZR050_COM_IDX, 0xff);
		zr36050_write(ptr, ZR050_COM_IDX + 1, 0xfe);
		zr36050_write(ptr, ZR050_COM_IDX + 2, 0x00);
		zr36050_write(ptr, ZR050_COM_IDX + 3, ptr->com.len + 2);
		sum += zr36050_pushit(ptr, ZR050_COM_IDX + 4, 60,
				      ptr->com.data) + 4;

		/* 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);
		dprintk(2, "%s: Status after table preload: 0x%02x\n",
			ptr->name, ptr->status1);

		if ((ptr->status1 & 0x4) == 0) {
			dprintk(1, KERN_ERR "%s: init aborted!\n",
				ptr->name);
			return;	// something is wrong, its timed out!!!!
		}

		/* setup misc. data for compression (target code sizes) */

		/* size of compressed code to reach without header data */
		sum = ptr->real_code_vol - sum;
		bitcnt = sum << 3;	/* need the size in bits */

		tmp = bitcnt >> 16;
		dprintk(3,
			"%s: code: csize=%d, tot=%d, bit=%ld, highbits=%ld\n",
			ptr->name, sum, ptr->real_code_vol, bitcnt, tmp);
		zr36050_write(ptr, ZR050_TCV_NET_HI, tmp >> 8);
		zr36050_write(ptr, ZR050_TCV_NET_MH, tmp & 0xff);
		tmp = bitcnt & 0xffff;
		zr36050_write(ptr, ZR050_TCV_NET_ML, tmp >> 8);
		zr36050_write(ptr, ZR050_TCV_NET_LO, tmp & 0xff);

		bitcnt -= bitcnt >> 7;	// bits without stuffing
		bitcnt -= ((bitcnt * 5) >> 6);	// bits without eob

		tmp = bitcnt >> 16;
		dprintk(3, "%s: code: nettobit=%ld, highnettobits=%ld\n",
			ptr->name, bitcnt, tmp);
		zr36050_write(ptr, ZR050_TCV_DATA_HI, tmp >> 8);
		zr36050_write(ptr, ZR050_TCV_DATA_MH, tmp & 0xff);
		tmp = bitcnt & 0xffff;
		zr36050_write(ptr, ZR050_TCV_DATA_ML, tmp >> 8);
		zr36050_write(ptr, ZR050_TCV_DATA_LO, tmp & 0xff);

		/* 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));

		/* this headers seem to deliver "valid AVI" jpeg frames */
		zr36050_write(ptr, ZR050_MARKERS_EN,
			      ZR050_ME_DQT | ZR050_ME_DHT |
			      ((ptr->app.len > 0) ? ZR050_ME_APP : 0) |
			      ((ptr->com.len > 0) ? ZR050_ME_COM : 0));
	} else {
コード例 #5
0
static void
zr36050_init (struct zr36050 *ptr)
{
	int sum = 0;
	long bitcnt, tmp;

	if (ptr->mode == CODEC_DO_COMPRESSION) {
		dprintk(2, "%s: COMPRESSION SETUP\n", ptr->name);

		/*                                          */
		zr36050_write(ptr, ZR050_HARDWARE, ZR050_HW_MSTR);

		/*                                        */
		zr36050_write(ptr, ZR050_MODE,
			      ZR050_MO_COMP | ZR050_MO_TLM);
		zr36050_write(ptr, ZR050_OPTIONS, 0);

		/*                  */
		zr36050_write(ptr, ZR050_INT_REQ_0, 0);
		zr36050_write(ptr, ZR050_INT_REQ_1, 3);	//                    

		/*                         */
		/*                                                   */
		zr36050_write(ptr, ZR050_SF_HI, ptr->scalefact >> 8);
		zr36050_write(ptr, ZR050_SF_LO, ptr->scalefact & 0xff);

		zr36050_write(ptr, ZR050_AF_HI, 0xff);
		zr36050_write(ptr, ZR050_AF_M, 0xff);
		zr36050_write(ptr, ZR050_AF_LO, 0xff);

		/*                                */
		sum += zr36050_set_sof(ptr);
		sum += zr36050_set_sos(ptr);
		sum += zr36050_set_dri(ptr);

		/*                                                       
                                    */
		dprintk(3, "%s: write DQT, DHT, APP\n", ptr->name);
		sum += zr36050_pushit(ptr, ZR050_DQT_IDX,
				      sizeof(zr36050_dqt), zr36050_dqt);
		sum += zr36050_pushit(ptr, ZR050_DHT_IDX,
				      sizeof(zr36050_dht), zr36050_dht);
		zr36050_write(ptr, ZR050_APP_IDX, 0xff);
		zr36050_write(ptr, ZR050_APP_IDX + 1, 0xe0 + ptr->app.appn);
		zr36050_write(ptr, ZR050_APP_IDX + 2, 0x00);
		zr36050_write(ptr, ZR050_APP_IDX + 3, ptr->app.len + 2);
		sum += zr36050_pushit(ptr, ZR050_APP_IDX + 4, 60,
				      ptr->app.data) + 4;
		zr36050_write(ptr, ZR050_COM_IDX, 0xff);
		zr36050_write(ptr, ZR050_COM_IDX + 1, 0xfe);
		zr36050_write(ptr, ZR050_COM_IDX + 2, 0x00);
		zr36050_write(ptr, ZR050_COM_IDX + 3, ptr->com.len + 2);
		sum += zr36050_pushit(ptr, ZR050_COM_IDX + 4, 60,
				      ptr->com.data) + 4;

		/*                                       */
		zr36050_write(ptr, ZR050_MARKERS_EN, ZR050_ME_DHTI);

		zr36050_write(ptr, ZR050_GO, 1);	//             
		zr36050_wait_end(ptr);
		dprintk(2, "%s: Status after table preload: 0x%02x\n",
			ptr->name, ptr->status1);

		if ((ptr->status1 & 0x4) == 0) {
			dprintk(1, KERN_ERR "%s: init aborted!\n",
				ptr->name);
			return;	//                                      
		}

		/*                                                      */

		/*                                                      */
		sum = ptr->real_code_vol - sum;
		bitcnt = sum << 3;	/*                       */

		tmp = bitcnt >> 16;
		dprintk(3,
			"%s: code: csize=%d, tot=%d, bit=%ld, highbits=%ld\n",
			ptr->name, sum, ptr->real_code_vol, bitcnt, tmp);
		zr36050_write(ptr, ZR050_TCV_NET_HI, tmp >> 8);
		zr36050_write(ptr, ZR050_TCV_NET_MH, tmp & 0xff);
		tmp = bitcnt & 0xffff;
		zr36050_write(ptr, ZR050_TCV_NET_ML, tmp >> 8);
		zr36050_write(ptr, ZR050_TCV_NET_LO, tmp & 0xff);

		bitcnt -= bitcnt >> 7;	//                      
		bitcnt -= ((bitcnt * 5) >> 6);	//                 

		tmp = bitcnt >> 16;
		dprintk(3, "%s: code: nettobit=%ld, highnettobits=%ld\n",
			ptr->name, bitcnt, tmp);
		zr36050_write(ptr, ZR050_TCV_DATA_HI, tmp >> 8);
		zr36050_write(ptr, ZR050_TCV_DATA_MH, tmp & 0xff);
		tmp = bitcnt & 0xffff;
		zr36050_write(ptr, ZR050_TCV_DATA_ML, tmp >> 8);
		zr36050_write(ptr, ZR050_TCV_DATA_LO, tmp & 0xff);

		/*                                                   */
		zr36050_write(ptr, ZR050_MODE,
			      ZR050_MO_COMP | ZR050_MO_PASS2 |
			      (ptr->bitrate_ctrl ? ZR050_MO_BRC : 0));

		/*                                                      */
		zr36050_write(ptr, ZR050_MARKERS_EN,
			      ZR050_ME_DQT | ZR050_ME_DHT |
			      ((ptr->app.len > 0) ? ZR050_ME_APP : 0) |
			      ((ptr->com.len > 0) ? ZR050_ME_COM : 0));
	} else {