Skip to content

drivers/lcd: Add ioctl to get LCD panel ID#7103

Draft
seokhun-eom24 wants to merge 2 commits intoSamsung:masterfrom
seokhun-eom24:251224-lcd-id-ioctl
Draft

drivers/lcd: Add ioctl to get LCD panel ID#7103
seokhun-eom24 wants to merge 2 commits intoSamsung:masterfrom
seokhun-eom24:251224-lcd-id-ioctl

Conversation

@seokhun-eom24
Copy link
Copy Markdown
Contributor

@seokhun-eom24 seokhun-eom24 commented Dec 29, 2025

drivers/lcd

  • Add LCDDEVIO_GETPANELID ioctl command to read 24-bit panel ID.
  • Implement getpanelid in MIPI LCD driver.
  • Require CMD mode for panel ID read operation.

examples

  • Add lcd_get_panelid() to retrieve and display the 24-bit LCD panel ID.
  • Update show_usage() and main() to support the "panelid" command.

[USAGE]

TASH>>lcd_test panelid
TASH>>LCD Panel ID: 0x010000

Comment thread os/drivers/lcd/mipi_lcd.c Outdated
};

static struct mipi_lcd_dev_s g_lcdcdev;
static bool g_panelid_initialized = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use private struct variable instead of global.?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, we can add it into get_lcdinfo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified it to use a member variable of mipi_lcd_dev_s instead of a global variable.
I separated get_lcdinfo and created a separate displayid because lcdinfo uses a static CONFIG value, while displayid dynamically retrieves the ID of the connected display.

Comment thread os/drivers/lcd/mipi_lcd.c Outdated
};

static struct mipi_lcd_dev_s g_lcdcdev;
static bool g_panelid_initialized = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, we can add it into get_lcdinfo.

Comment thread os/drivers/lcd/mipi_lcd.c Outdated
FAR struct mipi_lcd_dev_s *priv = (FAR struct mipi_lcd_dev_s *)dev;
int status;
lcd_mode_t original_mode;
lcm_setting_table_t read_id_cmd = {0x04, 0, {0x00}};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is This command DSC?
If it is specific command, we can wrapping this command to configure or new lcd sepecific api

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it's DSC.
So I tired to implement mipi_dsi_dcs_get_display_id function in mipi_dsi_device.c like below.

int mipi_dsi_dcs_get_display_id(FAR struct mipi_dsi_device *device, FAR uint32_t *displayid)
{
	int ret;
	uint8_t rxbuf[3];
	uint8_t length = sizeof(rxbuf) / sizeof(rxbuf[0]);

	ret = mipi_dsi_set_maximum_return_packet_size(device, length);
	if (ret < 0) {
		return ret;
	}

	ret = mipi_dsi_generic_read(device, MIPI_DCS_GET_DISPLAY_ID, 0, rxbuf, length);
	if (ret < 0) {
		return ret;
	}

	*displayid = (rxbuf[0] << 16) | (rxbuf[1] << 8) | rxbuf[2];
	return OK;
}

But we have issue with this approach.
In mipi_lcd.c command is stored in msg.channel like msg.channel = cmd;.
In mipi_dsi_device.c command is stored in tx_buf like msg.tx_buf = &cmd;.
In BSP code, we assume cmd is stored in msg.channel and also stored in packet.header[0] use that value in amebasmart_mipi_transfer.
But mipi_dsi_device.c's approach is standard.

So, before we wrapping this command with dcs function like mipi_dsi_dcs_get_display_id, we should refactor mipi_lcd.c and bsp code to follow dcs command format.

@seokhun-eom24 seokhun-eom24 force-pushed the 251224-lcd-id-ioctl branch 2 times, most recently from ee6b0c4 to 0839329 Compare January 6, 2026 02:03
Comment thread os/drivers/lcd/mipi_lcd.c
priv->displayid = (rxbuf[0] << 16) | (rxbuf[1] << 8) | rxbuf[2];
*displayid = priv->displayid;
priv->displayid_initialized = true;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no chance to fail the function read_response or set_return_packet_len?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, the read_response and set_return_packet_len functions can also fail.
In this case, the if case will not be executed, but the cleanup operation must still be performed in the same way, so no separate else handling was added.

Comment thread apps/examples/lcd_test/example_lcd.c Outdated
if (argc == 2) {
if (!strncmp(argv[1], "lcdinfo", 8)) {
return lcd_get_info();
} else if (!strncmp(argv[1], "displayid", 8)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third argument need to be 9.

Suggested change
} else if (!strncmp(argv[1], "displayid", 8)) {
} else if (!strncmp(argv[1], "displayid", 9)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for finding this, as I missed this part while changing the command from panelid to displayid.
I corrected it to 10 (length + 1) for an exact string match.

Comment thread os/drivers/lcd/mipi_lcd.c Outdated
priv->config = config;
priv->power = 0;
priv->lcdonoff = LCD_OFF;
priv->displayid = 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if displayid is used often, it's better to store id to ram.
But, i think, this id is not used often.

So, we don't need to store

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Mr Nam, display id will not be used frequently from ioctl so we might skip storing it and just read it directly from h/w. Do we know which scenario it will be used ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated to not store displayid in RAM.

We support different vendors for LCD. So when we have a hardware issue with an LCD panel, we want to know which vendor’s LCD it is. In this scenario we need to know the displayid.

@seokhun-eom24 seokhun-eom24 force-pushed the 251224-lcd-id-ioctl branch 2 times, most recently from 729e131 to 68876c8 Compare February 3, 2026 00:55
- Add LCDDEVIO_GETDISPLAYID ioctl command to read 24-bit display ID.
- Implement getdisplayid in MIPI LCD driver.
- Require CMD mode for display ID read operation.

Signed-off-by: seokhun-eom <seokhun.eom@samsung.com>
- Add lcd_get_displayid() to retrieve and display the 24-bit LCD display ID.
- Update show_usage() and main() to support the "displayid" command.

[USAGE]
```
TASH>>lcd_test displayid
TASH>>LCD Panel ID: 0x010000
```

Signed-off-by: seokhun-eom <seokhun.eom@samsung.com>
@@ -65,6 +65,7 @@
#define LCDDEVIO_INIT _LCDIOC(18)
#define LCDDEVIO_SETORIENTATION _LCDIOC(19) /* Arg: int */
#define LCDDEVIO_GETLCDINFO _LCDIOC(20) /* Arg: struct lcd_info_s* Description: Get the static LCD characteristics such as width, height, size and DPI. */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lcd init is already exist.
how about use it ?

return ret;
}

static int lcd_get_displayid(void)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

App should not take care of vendor of LCD, it must be abstracted.
Even if there are some types of LCD, framework & App should not change api of code. otherwise it is not good driver & framework model.
Hence I think you should not remove ioctl, and print out id of lcd when LCD initailized, that is enough.

@seokhun-eom24 seokhun-eom24 marked this pull request as draft February 13, 2026 08:15
@seokhun-eom24
Copy link
Copy Markdown
Contributor Author

I'll handle this PR after merge #7018

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

Successfully merging this pull request may close these issues.

5 participants