drivers/media/dvb-frontends/drxk_hard.c

Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/drxk_hard.c

File Facts

System
Linux kernel
Corpus path
drivers/media/dvb-frontends/drxk_hard.c
Extension
.c
Size
179740 bytes
Lines
6821
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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 (DRXDAP_FASI_LONG_FORMAT(address) || (flags != 0)) {
			adr_buf[0] = (((address << 1) & 0xFF) | 0x01);
			adr_buf[1] = ((address >> 16) & 0xFF);
			adr_buf[2] = ((address >> 24) & 0xFF);
			adr_buf[3] = ((address >> 7) & 0xFF);
			adr_buf[2] |= flags;
			adr_length = 4;
			if (chunk == state->m_chunk_size)
				chunk -= 2;
		} else {
			adr_buf[0] = ((address << 1) & 0xFF);
			adr_buf[1] = (((address >> 16) & 0x0F) |
				     ((address >> 18) & 0xF0));
			adr_length = 2;
		}
		memcpy(&state->chunk[adr_length], p_block, chunk);
		dprintk(2, "(0x%08x, 0x%02x)\n", address, flags);
		if (p_block)
			dprintk(2, "%*ph\n", chunk, p_block);
		status = i2c_write(state, state->demod_address,
				   &state->chunk[0], chunk + adr_length);
		if (status < 0) {
			pr_err("%s: i2c write error at addr 0x%02x\n",
			       __func__, address);
			break;
		}
		p_block += chunk;
		address += (chunk >> 1);
		blk_size -= chunk;
	}
	return status;
}

#ifndef DRXK_MAX_RETRIES_POWERUP
#define DRXK_MAX_RETRIES_POWERUP 20
#endif

static int power_up_device(struct drxk_state *state)
{
	int status;
	u8 data = 0;
	u16 retry_count = 0;

	dprintk(1, "\n");

	status = i2c_read1(state, state->demod_address, &data);
	if (status < 0) {
		do {
			data = 0;
			status = i2c_write(state, state->demod_address,
					   &data, 1);
			usleep_range(10000, 11000);
			retry_count++;
			if (status < 0)
				continue;
			status = i2c_read1(state, state->demod_address,
					   &data);
		} while (status < 0 &&
			 (retry_count < DRXK_MAX_RETRIES_POWERUP));
		if (status < 0 && retry_count >= DRXK_MAX_RETRIES_POWERUP)
			goto error;
	}

	/* Make sure all clk domains are active */
	status = write16(state, SIO_CC_PWD_MODE__A, SIO_CC_PWD_MODE_LEVEL_NONE);
	if (status < 0)
		goto error;
	status = write16(state, SIO_CC_UPDATE__A, SIO_CC_UPDATE_KEY);
	if (status < 0)
		goto error;
	/* Enable pll lock tests */
	status = write16(state, SIO_CC_PLL_LOCK__A, 1);
	if (status < 0)
		goto error;

	state->m_current_power_mode = DRX_POWER_UP;

error:
	if (status < 0)
		pr_err("Error %d on %s\n", status, __func__);

	return status;
}


static int init_state(struct drxk_state *state)
{
	/*
	 * FIXME: most (all?) of the values below should be moved into
	 * struct drxk_config, as they are probably board-specific

Annotation

Implementation Notes