Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDID as control channel - possible? #3

Open
showier-drastic opened this issue Dec 11, 2024 · 1 comment
Open

EDID as control channel - possible? #3

showier-drastic opened this issue Dec 11, 2024 · 1 comment

Comments

@showier-drastic
Copy link

Hi,

I would like to ask whether it is possible to turn the EDID I2C into a downstream control channel? Maybe via some magic usb command to modify EDID table?

@steve-m
Copy link
Owner

steve-m commented Dec 11, 2024

Yes, that is possible. So far there was no real use for this, so I didn't really clean up the code and commit it. Did that now in 9b910ef.

Here is some example code I used for testing.

Host side, can be plugged into hsdaoh_test.c:

int cnt = 1;
char message[256];

while (!do_exit) {
	sprintf(message, "Hello World via EDID #%d", cnt++);
	hsdaoh_write_edid_cmd_data(dev, (uint8_t *)message, strlen(message));
	usleep(100000);
}

Program running on a Raspberry Pi Pico connected via I2C to the MS2130:

#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/i2c.h"

int main()
{
	stdio_init_all();

	i2c_init(i2c_default, 100 * 1000);
	gpio_set_function(PICO_DEFAULT_I2C_SDA_PIN, GPIO_FUNC_I2C);
	gpio_set_function(PICO_DEFAULT_I2C_SCL_PIN, GPIO_FUNC_I2C);
	gpio_pull_up(PICO_DEFAULT_I2C_SDA_PIN);
	gpio_pull_up(PICO_DEFAULT_I2C_SCL_PIN);

	int ret;
	uint8_t txdata = 0;
	uint8_t rxdata;
	uint8_t msglen;
	uint8_t seq = 0x01;
	uint8_t last_seq = 0;

	while (true) {
		/* read sequence number */
		txdata = 0;
		ret = i2c_write_blocking(i2c_default, 0x50, &txdata, 1, false);
		if (ret < 0)
			continue;

		ret = i2c_read_blocking(i2c_default, 0x50, &rxdata, 1, false);
		if (ret < 0)
			continue;

		if ((rxdata != 0xff) && (rxdata != 0x00)) {
			seq = rxdata;
			if (seq != last_seq) {
				/* read length field */
				txdata = 1;
				ret = i2c_write_blocking(i2c_default, 0x50, &txdata, 1, false);

				if (ret < 0)
					continue;


				ret = i2c_read_blocking(i2c_default, 0x50, &msglen, 1, false);

				if (ret < 0)
					continue;

				txdata = 2;
				ret = i2c_write_blocking(i2c_default, 0x50, &txdata, 1, false);
				if (ret < 0)
					continue;

				/* read actual message */
				char message[256];
				ret = i2c_read_blocking(i2c_default, 0x50, message, msglen, false);
				if (ret < 0)
					continue;

				message[msglen] = '\0';
				printf("New message with length %d: %s\n", msglen, message);

				last_seq = seq;
			}
		}
	}

	return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants