drivers/media/pci/zoran/zr36050.c

Source file repositories/reference/linux-study-clean/drivers/media/pci/zoran/zr36050.c

File Facts

System
Linux kernel
Corpus path
drivers/media/pci/zoran/zr36050.c
Extension
.c
Size
23836 bytes
Lines
818
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (i++ > 200000) {	// 200ms, there is for sure something wrong!!!
			zrdev_err(zr,
				  "%s: timeout at wait_end (last status: 0x%02x)\n",
				  ptr->name, ptr->status1);
			break;
		}
	}
}

/*
 * Local helper function: basic test of "connectivity", writes/reads
 * to/from memory the SOF marker
 */

static int zr36050_basic_test(struct zr36050 *ptr)
{
	struct zoran *zr = videocodec_to_zoran(ptr->codec);

	zr36050_write(ptr, ZR050_SOF_IDX, 0x00);
	zr36050_write(ptr, ZR050_SOF_IDX + 1, 0x00);
	if ((zr36050_read(ptr, ZR050_SOF_IDX) |
	     zr36050_read(ptr, ZR050_SOF_IDX + 1)) != 0x0000) {
		zrdev_err(zr,
			  "%s: attach failed, can't connect to jpeg processor!\n",
			  ptr->name);
		return -ENXIO;
	}
	zr36050_write(ptr, ZR050_SOF_IDX, 0xff);
	zr36050_write(ptr, ZR050_SOF_IDX + 1, 0xc0);
	if (((zr36050_read(ptr, ZR050_SOF_IDX) << 8) |
	     zr36050_read(ptr, ZR050_SOF_IDX + 1)) != 0xffc0) {
		zrdev_err(zr,
			  "%s: attach failed, can't connect to jpeg processor!\n",
			  ptr->name);
		return -ENXIO;
	}

	zr36050_wait_end(ptr);
	if ((ptr->status1 & 0x4) == 0) {
		zrdev_err(zr,
			  "%s: attach failed, jpeg processor failed (end flag)!\n",
			  ptr->name);
		return -EBUSY;
	}

	return 0;		/* looks good! */
}

/* Local helper function: simple loop for pushing the init datasets */

static int zr36050_pushit(struct zr36050 *ptr, u16 startreg, u16 len, const char *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.
 */

static const char zr36050_dqt[0x86] = {
	0xff, 0xdb,		//Marker: DQT
	0x00, 0x84,		//Length: 2*65+2
	0x00,			//Pq,Tq first table
	0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e,
	0x0d, 0x0e, 0x12, 0x11, 0x10, 0x13, 0x18, 0x28,
	0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23, 0x25,
	0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 0x39, 0x33,
	0x38, 0x37, 0x40, 0x48, 0x5c, 0x4e, 0x40, 0x44,
	0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 0x51, 0x57,
	0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71,
	0x79, 0x70, 0x64, 0x78, 0x5c, 0x65, 0x67, 0x63,
	0x01,			//Pq,Tq second table
	0x11, 0x12, 0x12, 0x18, 0x15, 0x18, 0x2f, 0x1a,
	0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42, 0x63, 0x63,
	0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,

Annotation

Implementation Notes