Exemple #1
0
def _generate_dcs_write(t: Transaction, payload: bytes, options: Options) -> str:
	# TODO: Warn when downstream uses LONG_WRITE but mainline would use SHORT

	dcs = DCSCommand.find(payload, options.dumb_dcs)
	if dcs and dcs.method:
		return _generate_checked_call(dcs.method, dcs.get_params(payload[1:]), dcs.description)

	params = _get_params_hex(payload)
	if dcs:
		params[0] = dcs.identifier
	params.insert(0, 'dsi')

	return wrap.join('\tdsi_dcs_write_seq(', ',', ');', params, force=2)
Exemple #2
0
def generate_commands(p: Panel, cmd_name: str) -> str:
    cmd: CommandSequence = p.cmds[cmd_name]

    cmds = ""
    struct = f"static struct mipi_dsi_cmd {p.id}_{cmd_name}_command[] = {{\n"

    s = ""
    i = 0
    for c in cmd.seq:
        b = bytearray()
        long = c.type.is_long
        if long:
            b += int.to_bytes(len(c.payload), 2, 'little')  # Word count (WC)
        else:
            assert len(c.payload) <= 2, f"Payload too long: {len(c.payload)}"
            itr = iter(c.payload)
            b.append(next(itr, 0))
            b.append(next(itr, 0))

        b.append(c.type.value | c.vc << 6)
        b.append(int(c.ack) << 5 | int(long) << 6 | int(c.last) << 7)

        if long:
            b += bytes(c.payload)

            # DMA command size must be multiple of 4
            mod = len(b) % 4
            if mod != 0:
                b += bytes([0xff] * (4 - mod))

        name = f'{p.id}_{cmd_name}_cmd_{i}'
        cmds += f'static char {name}[] = {{\n'
        cmds += wrap.join('\t',
                          ',',
                          '', [f'{byte:#04x}' for byte in b],
                          wrap=54)
        cmds += '\n};\n'

        struct += f'\t{{ sizeof({name}), {name}, {c.wait} }},\n'
        i += 1

    struct += '};'

    return cmds + '\n' + struct
Exemple #3
0
def _generate_generic_write(t: Transaction, payload: bytes,
                            options: Options) -> str:
    # TODO: Warn when downstream uses LONG_WRITE but mainline would use SHORT
    params = _get_params_hex(payload)
    params.insert(0, 'dsi')
    return wrap.join('\tdsi_generic_write_seq(', ',', ');', params, force=2)