drivers/media/cec/core/cec-pin-error-inj.c

Source file repositories/reference/linux-study-clean/drivers/media/cec/core/cec-pin-error-inj.c

File Facts

System
Linux kernel
Corpus path
drivers/media/cec/core/cec-pin-error-inj.c
Extension
.c
Size
13589 bytes
Lines
404
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

struct cec_error_inj_cmd {
	unsigned int mode_offset;
	int arg_idx;
	const char *cmd;
};

static const struct cec_error_inj_cmd cec_error_inj_cmds[] = {
	{ CEC_ERROR_INJ_RX_NACK_OFFSET, -1, "rx-nack" },
	{ CEC_ERROR_INJ_RX_LOW_DRIVE_OFFSET,
	  CEC_ERROR_INJ_RX_LOW_DRIVE_ARG_IDX, "rx-low-drive" },
	{ CEC_ERROR_INJ_RX_ADD_BYTE_OFFSET, -1, "rx-add-byte" },
	{ CEC_ERROR_INJ_RX_REMOVE_BYTE_OFFSET, -1, "rx-remove-byte" },
	{ CEC_ERROR_INJ_RX_ARB_LOST_OFFSET,
	  CEC_ERROR_INJ_RX_ARB_LOST_ARG_IDX, "rx-arb-lost" },

	{ CEC_ERROR_INJ_TX_NO_EOM_OFFSET, -1, "tx-no-eom" },
	{ CEC_ERROR_INJ_TX_EARLY_EOM_OFFSET, -1, "tx-early-eom" },
	{ CEC_ERROR_INJ_TX_ADD_BYTES_OFFSET,
	  CEC_ERROR_INJ_TX_ADD_BYTES_ARG_IDX, "tx-add-bytes" },
	{ CEC_ERROR_INJ_TX_REMOVE_BYTE_OFFSET, -1, "tx-remove-byte" },
	{ CEC_ERROR_INJ_TX_SHORT_BIT_OFFSET,
	  CEC_ERROR_INJ_TX_SHORT_BIT_ARG_IDX, "tx-short-bit" },
	{ CEC_ERROR_INJ_TX_LONG_BIT_OFFSET,
	  CEC_ERROR_INJ_TX_LONG_BIT_ARG_IDX, "tx-long-bit" },
	{ CEC_ERROR_INJ_TX_CUSTOM_BIT_OFFSET,
	  CEC_ERROR_INJ_TX_CUSTOM_BIT_ARG_IDX, "tx-custom-bit" },
	{ CEC_ERROR_INJ_TX_SHORT_START_OFFSET, -1, "tx-short-start" },
	{ CEC_ERROR_INJ_TX_LONG_START_OFFSET, -1, "tx-long-start" },
	{ CEC_ERROR_INJ_TX_CUSTOM_START_OFFSET, -1, "tx-custom-start" },
	{ CEC_ERROR_INJ_TX_LAST_BIT_OFFSET,
	  CEC_ERROR_INJ_TX_LAST_BIT_ARG_IDX, "tx-last-bit" },
	{ CEC_ERROR_INJ_TX_LOW_DRIVE_OFFSET,
	  CEC_ERROR_INJ_TX_LOW_DRIVE_ARG_IDX, "tx-low-drive" },
	{ 0, -1, NULL }
};

u16 cec_pin_rx_error_inj(struct cec_pin *pin)
{
	u16 cmd = CEC_ERROR_INJ_OP_ANY;

	/* Only when 18 bits have been received do we have a valid cmd */
	if (!(pin->error_inj[cmd] & CEC_ERROR_INJ_RX_MASK) &&
	    pin->rx_bit >= 18)
		cmd = pin->rx_msg.msg[1];
	return (pin->error_inj[cmd] & CEC_ERROR_INJ_RX_MASK) ? cmd :
		CEC_ERROR_INJ_OP_ANY;
}

u16 cec_pin_tx_error_inj(struct cec_pin *pin)
{
	u16 cmd = CEC_ERROR_INJ_OP_ANY;

	if (!(pin->error_inj[cmd] & CEC_ERROR_INJ_TX_MASK) &&
	    pin->tx_msg.len > 1)
		cmd = pin->tx_msg.msg[1];
	return (pin->error_inj[cmd] & CEC_ERROR_INJ_TX_MASK) ? cmd :
		CEC_ERROR_INJ_OP_ANY;
}

bool cec_pin_error_inj_parse_line(struct cec_adapter *adap, char *line)
{
	static const char *delims = " \t\r";
	struct cec_pin *pin = adap->pin;
	unsigned int i;
	bool has_pos = false;
	char *p = line;
	char *token;
	char *comma;
	u64 *error;
	u8 *args;
	bool has_op;
	u8 op;
	u8 mode;
	u8 pos;

	p = skip_spaces(p);
	token = strsep(&p, delims);
	if (!strcmp(token, "clear")) {
		memset(pin->error_inj, 0, sizeof(pin->error_inj));
		pin->rx_toggle = pin->tx_toggle = false;
		pin->rx_no_low_drive = false;
		pin->tx_ignore_nack_until_eom = false;
		pin->tx_custom_pulse = false;
		pin->tx_custom_low_usecs = CEC_TIM_CUSTOM_DEFAULT;
		pin->tx_custom_high_usecs = CEC_TIM_CUSTOM_DEFAULT;
		pin->tx_glitch_low_usecs = CEC_TIM_GLITCH_DEFAULT;
		pin->tx_glitch_high_usecs = CEC_TIM_GLITCH_DEFAULT;
		pin->tx_glitch_falling_edge = false;
		pin->tx_glitch_rising_edge = false;
		return true;

Annotation

Implementation Notes