mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 13:44:15 +08:00
drm/tinydrm: Split struct mipi_dbi in two
Split struct mipi_dbi into an interface part and a display pipeline part. The interface part can be used by drivers that need to initialize the controller, but that won't upload the framebuffer over this interface. MIPI DBI supports 3 interface types: - A. Motorola 6800 type parallel bus - B. Intel 8080 type parallel bus - C. SPI type with 3 options: I've embedded the SPI type specifics in the mipi_dbi struct to avoid adding unnecessary complexity. If more interface types will be supported in the future, the type specifics might have to be split out. Rename functions to match the new struct mipi_dbi_dev: - drm_to_mipi_dbi() -> drm_to_mipi_dbi_dev(). - mipi_dbi_init*() -> mipi_dbi_dev_init*(). Cc: Eric Anholt <eric@anholt.net> Cc: David Lechner <david@lechnology.com> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Noralf Trønnes <noralf@tronnes.org> Acked-by: David Lechner <david@lechnology.com> Acked-by: Eric Anholt <eric@anholt.net> Link: https://patchwork.freedesktop.org/patch/msgid/20190722104312.16184-5-noralf@tronnes.org
This commit is contained in:
parent
440961d209
commit
84137b866e
@ -47,8 +47,8 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe,
|
||||
struct drm_crtc_state *crtc_state,
|
||||
struct drm_plane_state *plane_state)
|
||||
{
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev);
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
u8 addr_mode;
|
||||
int ret, idx;
|
||||
|
||||
@ -220,7 +220,7 @@ MODULE_DEVICE_TABLE(spi, hx8357d_id);
|
||||
static int hx8357d_probe(struct spi_device *spi)
|
||||
{
|
||||
struct device *dev = &spi->dev;
|
||||
struct mipi_dbi *dbidev;
|
||||
struct mipi_dbi_dev *dbidev;
|
||||
struct drm_device *drm;
|
||||
struct gpio_desc *dc;
|
||||
u32 rotation = 0;
|
||||
@ -251,11 +251,11 @@ static int hx8357d_probe(struct spi_device *spi)
|
||||
|
||||
device_property_read_u32(dev, "rotation", &rotation);
|
||||
|
||||
ret = mipi_dbi_spi_init(spi, dbidev, dc);
|
||||
ret = mipi_dbi_spi_init(spi, &dbidev->dbi, dc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = mipi_dbi_init(dbidev, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation);
|
||||
ret = mipi_dbi_dev_init(dbidev, &hx8357d_pipe_funcs, &yx350hv15_mode, rotation);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -78,10 +78,10 @@ static inline int ili9225_command(struct mipi_dbi *dbi, u8 cmd, u16 data)
|
||||
static void ili9225_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
|
||||
{
|
||||
struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(fb->dev);
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev);
|
||||
unsigned int height = rect->y2 - rect->y1;
|
||||
unsigned int width = rect->x2 - rect->x1;
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
bool swap = dbi->swap_bytes;
|
||||
u16 x_start, y_start;
|
||||
u16 x1, x2, y1, y2;
|
||||
@ -183,10 +183,10 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
|
||||
struct drm_crtc_state *crtc_state,
|
||||
struct drm_plane_state *plane_state)
|
||||
{
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev);
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
|
||||
struct drm_framebuffer *fb = plane_state->fb;
|
||||
struct device *dev = pipe->crtc.dev->dev;
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
struct drm_rect rect = {
|
||||
.x1 = 0,
|
||||
.x2 = fb->width,
|
||||
@ -291,8 +291,8 @@ out_exit:
|
||||
|
||||
static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe)
|
||||
{
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev);
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
|
||||
DRM_DEBUG_KMS("\n");
|
||||
|
||||
@ -378,7 +378,7 @@ MODULE_DEVICE_TABLE(spi, ili9225_id);
|
||||
static int ili9225_probe(struct spi_device *spi)
|
||||
{
|
||||
struct device *dev = &spi->dev;
|
||||
struct mipi_dbi *dbidev;
|
||||
struct mipi_dbi_dev *dbidev;
|
||||
struct drm_device *drm;
|
||||
struct mipi_dbi *dbi;
|
||||
struct gpio_desc *rs;
|
||||
@ -389,7 +389,7 @@ static int ili9225_probe(struct spi_device *spi)
|
||||
if (!dbidev)
|
||||
return -ENOMEM;
|
||||
|
||||
dbi = dbidev;
|
||||
dbi = &dbidev->dbi;
|
||||
drm = &dbidev->drm;
|
||||
ret = devm_drm_dev_init(dev, drm, &ili9225_driver);
|
||||
if (ret) {
|
||||
@ -420,7 +420,7 @@ static int ili9225_probe(struct spi_device *spi)
|
||||
/* override the command function set in mipi_dbi_spi_init() */
|
||||
dbi->command = ili9225_dbi_command;
|
||||
|
||||
ret = mipi_dbi_init(dbidev, &ili9225_pipe_funcs, &ili9225_mode, rotation);
|
||||
ret = mipi_dbi_dev_init(dbidev, &ili9225_pipe_funcs, &ili9225_mode, rotation);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -53,8 +53,8 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe,
|
||||
struct drm_crtc_state *crtc_state,
|
||||
struct drm_plane_state *plane_state)
|
||||
{
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev);
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
u8 addr_mode;
|
||||
int ret, idx;
|
||||
|
||||
@ -176,7 +176,7 @@ MODULE_DEVICE_TABLE(spi, ili9341_id);
|
||||
static int ili9341_probe(struct spi_device *spi)
|
||||
{
|
||||
struct device *dev = &spi->dev;
|
||||
struct mipi_dbi *dbidev;
|
||||
struct mipi_dbi_dev *dbidev;
|
||||
struct drm_device *drm;
|
||||
struct mipi_dbi *dbi;
|
||||
struct gpio_desc *dc;
|
||||
@ -187,7 +187,7 @@ static int ili9341_probe(struct spi_device *spi)
|
||||
if (!dbidev)
|
||||
return -ENOMEM;
|
||||
|
||||
dbi = dbidev;
|
||||
dbi = &dbidev->dbi;
|
||||
drm = &dbidev->drm;
|
||||
ret = devm_drm_dev_init(dev, drm, &ili9341_driver);
|
||||
if (ret) {
|
||||
@ -219,7 +219,7 @@ static int ili9341_probe(struct spi_device *spi)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = mipi_dbi_init(dbidev, &ili9341_pipe_funcs, &yx240qv29_mode, rotation);
|
||||
ret = mipi_dbi_dev_init(dbidev, &ili9341_pipe_funcs, &yx240qv29_mode, rotation);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -51,8 +51,8 @@ static void mi0283qt_enable(struct drm_simple_display_pipe *pipe,
|
||||
struct drm_crtc_state *crtc_state,
|
||||
struct drm_plane_state *plane_state)
|
||||
{
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev);
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
u8 addr_mode;
|
||||
int ret, idx;
|
||||
|
||||
@ -180,7 +180,7 @@ MODULE_DEVICE_TABLE(spi, mi0283qt_id);
|
||||
static int mi0283qt_probe(struct spi_device *spi)
|
||||
{
|
||||
struct device *dev = &spi->dev;
|
||||
struct mipi_dbi *dbidev;
|
||||
struct mipi_dbi_dev *dbidev;
|
||||
struct drm_device *drm;
|
||||
struct mipi_dbi *dbi;
|
||||
struct gpio_desc *dc;
|
||||
@ -191,7 +191,7 @@ static int mi0283qt_probe(struct spi_device *spi)
|
||||
if (!dbidev)
|
||||
return -ENOMEM;
|
||||
|
||||
dbi = dbidev;
|
||||
dbi = &dbidev->dbi;
|
||||
drm = &dbidev->drm;
|
||||
ret = devm_drm_dev_init(dev, drm, &mi0283qt_driver);
|
||||
if (ret) {
|
||||
@ -227,7 +227,7 @@ static int mi0283qt_probe(struct spi_device *spi)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = mipi_dbi_init(dbidev, &mi0283qt_pipe_funcs, &mi0283qt_mode, rotation);
|
||||
ret = mipi_dbi_dev_init(dbidev, &mi0283qt_pipe_funcs, &mi0283qt_mode, rotation);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -241,10 +241,10 @@ EXPORT_SYMBOL(mipi_dbi_buf_copy);
|
||||
static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
|
||||
{
|
||||
struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(fb->dev);
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev);
|
||||
unsigned int height = rect->y2 - rect->y1;
|
||||
unsigned int width = rect->x2 - rect->x1;
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
bool swap = dbi->swap_bytes;
|
||||
int idx, ret = 0;
|
||||
bool full;
|
||||
@ -327,7 +327,7 @@ EXPORT_SYMBOL(mipi_dbi_pipe_update);
|
||||
* framebuffer flushing, can't use this function since they both use the same
|
||||
* flushing code.
|
||||
*/
|
||||
void mipi_dbi_enable_flush(struct mipi_dbi *dbidev,
|
||||
void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev,
|
||||
struct drm_crtc_state *crtc_state,
|
||||
struct drm_plane_state *plane_state)
|
||||
{
|
||||
@ -351,13 +351,13 @@ void mipi_dbi_enable_flush(struct mipi_dbi *dbidev,
|
||||
}
|
||||
EXPORT_SYMBOL(mipi_dbi_enable_flush);
|
||||
|
||||
static void mipi_dbi_blank(struct mipi_dbi *dbidev)
|
||||
static void mipi_dbi_blank(struct mipi_dbi_dev *dbidev)
|
||||
{
|
||||
struct drm_device *drm = &dbidev->drm;
|
||||
u16 height = drm->mode_config.min_height;
|
||||
u16 width = drm->mode_config.min_width;
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
size_t len = width * height * 2;
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
int idx;
|
||||
|
||||
if (!drm_dev_enter(drm, &idx))
|
||||
@ -385,7 +385,7 @@ static void mipi_dbi_blank(struct mipi_dbi *dbidev)
|
||||
*/
|
||||
void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe)
|
||||
{
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev);
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
|
||||
|
||||
if (!dbidev->enabled)
|
||||
return;
|
||||
@ -406,7 +406,7 @@ EXPORT_SYMBOL(mipi_dbi_pipe_disable);
|
||||
|
||||
static int mipi_dbi_connector_get_modes(struct drm_connector *connector)
|
||||
{
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(connector->dev);
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(connector->dev);
|
||||
struct drm_display_mode *mode;
|
||||
|
||||
mode = drm_mode_duplicate(connector->dev, &dbidev->mode);
|
||||
@ -470,7 +470,7 @@ static const uint32_t mipi_dbi_formats[] = {
|
||||
};
|
||||
|
||||
/**
|
||||
* mipi_dbi_init_with_formats - MIPI DBI initialization with custom formats
|
||||
* mipi_dbi_dev_init_with_formats - MIPI DBI device initialization with custom formats
|
||||
* @dbidev: MIPI DBI device structure to initialize
|
||||
* @funcs: Display pipe functions
|
||||
* @formats: Array of supported formats (DRM_FORMAT\_\*).
|
||||
@ -483,7 +483,7 @@ static const uint32_t mipi_dbi_formats[] = {
|
||||
* has one fixed &drm_display_mode which is rotated according to @rotation.
|
||||
* This mode is used to set the mode config min/max width/height properties.
|
||||
*
|
||||
* Use mipi_dbi_init() if you don't need custom formats.
|
||||
* Use mipi_dbi_dev_init() if you don't need custom formats.
|
||||
*
|
||||
* Note:
|
||||
* Some of the helper functions expects RGB565 to be the default format and the
|
||||
@ -492,11 +492,11 @@ static const uint32_t mipi_dbi_formats[] = {
|
||||
* Returns:
|
||||
* Zero on success, negative error code on failure.
|
||||
*/
|
||||
int mipi_dbi_init_with_formats(struct mipi_dbi *dbidev,
|
||||
const struct drm_simple_display_pipe_funcs *funcs,
|
||||
const uint32_t *formats, unsigned int format_count,
|
||||
const struct drm_display_mode *mode,
|
||||
unsigned int rotation, size_t tx_buf_size)
|
||||
int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev *dbidev,
|
||||
const struct drm_simple_display_pipe_funcs *funcs,
|
||||
const uint32_t *formats, unsigned int format_count,
|
||||
const struct drm_display_mode *mode,
|
||||
unsigned int rotation, size_t tx_buf_size)
|
||||
{
|
||||
static const uint64_t modifiers[] = {
|
||||
DRM_FORMAT_MOD_LINEAR,
|
||||
@ -505,7 +505,7 @@ int mipi_dbi_init_with_formats(struct mipi_dbi *dbidev,
|
||||
struct drm_device *drm = &dbidev->drm;
|
||||
int ret;
|
||||
|
||||
if (!dbidev->command)
|
||||
if (!dbidev->dbi.command)
|
||||
return -EINVAL;
|
||||
|
||||
dbidev->tx_buf = devm_kmalloc(drm->dev, tx_buf_size, GFP_KERNEL);
|
||||
@ -543,10 +543,10 @@ int mipi_dbi_init_with_formats(struct mipi_dbi *dbidev,
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(mipi_dbi_init_with_formats);
|
||||
EXPORT_SYMBOL(mipi_dbi_dev_init_with_formats);
|
||||
|
||||
/**
|
||||
* mipi_dbi_init - MIPI DBI initialization
|
||||
* mipi_dbi_dev_init - MIPI DBI device initialization
|
||||
* @dbidev: MIPI DBI device structure to initialize
|
||||
* @funcs: Display pipe functions
|
||||
* @mode: Display mode
|
||||
@ -562,19 +562,19 @@ EXPORT_SYMBOL(mipi_dbi_init_with_formats);
|
||||
* Returns:
|
||||
* Zero on success, negative error code on failure.
|
||||
*/
|
||||
int mipi_dbi_init(struct mipi_dbi *dbidev,
|
||||
const struct drm_simple_display_pipe_funcs *funcs,
|
||||
const struct drm_display_mode *mode, unsigned int rotation)
|
||||
int mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev,
|
||||
const struct drm_simple_display_pipe_funcs *funcs,
|
||||
const struct drm_display_mode *mode, unsigned int rotation)
|
||||
{
|
||||
size_t bufsize = mode->vdisplay * mode->hdisplay * sizeof(u16);
|
||||
|
||||
dbidev->drm.mode_config.preferred_depth = 16;
|
||||
|
||||
return mipi_dbi_init_with_formats(dbidev, funcs, mipi_dbi_formats,
|
||||
ARRAY_SIZE(mipi_dbi_formats), mode,
|
||||
rotation, bufsize);
|
||||
return mipi_dbi_dev_init_with_formats(dbidev, funcs, mipi_dbi_formats,
|
||||
ARRAY_SIZE(mipi_dbi_formats), mode,
|
||||
rotation, bufsize);
|
||||
}
|
||||
EXPORT_SYMBOL(mipi_dbi_init);
|
||||
EXPORT_SYMBOL(mipi_dbi_dev_init);
|
||||
|
||||
/**
|
||||
* mipi_dbi_release - DRM driver release helper
|
||||
@ -586,13 +586,13 @@ EXPORT_SYMBOL(mipi_dbi_init);
|
||||
*/
|
||||
void mipi_dbi_release(struct drm_device *drm)
|
||||
{
|
||||
struct mipi_dbi *dbi = drm_to_mipi_dbi(drm);
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(drm);
|
||||
|
||||
DRM_DEBUG_DRIVER("\n");
|
||||
|
||||
drm_mode_config_cleanup(drm);
|
||||
drm_dev_fini(drm);
|
||||
kfree(dbi);
|
||||
kfree(dbidev);
|
||||
}
|
||||
EXPORT_SYMBOL(mipi_dbi_release);
|
||||
|
||||
@ -646,10 +646,10 @@ bool mipi_dbi_display_is_on(struct mipi_dbi *dbi)
|
||||
}
|
||||
EXPORT_SYMBOL(mipi_dbi_display_is_on);
|
||||
|
||||
static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *dbidev, bool cond)
|
||||
static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi_dev *dbidev, bool cond)
|
||||
{
|
||||
struct device *dev = dbidev->drm.dev;
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
int ret;
|
||||
|
||||
if (dbidev->regulator) {
|
||||
@ -695,7 +695,7 @@ static int mipi_dbi_poweron_reset_conditional(struct mipi_dbi *dbidev, bool cond
|
||||
* Returns:
|
||||
* Zero on success, or a negative error code.
|
||||
*/
|
||||
int mipi_dbi_poweron_reset(struct mipi_dbi *dbidev)
|
||||
int mipi_dbi_poweron_reset(struct mipi_dbi_dev *dbidev)
|
||||
{
|
||||
return mipi_dbi_poweron_reset_conditional(dbidev, false);
|
||||
}
|
||||
@ -713,7 +713,7 @@ EXPORT_SYMBOL(mipi_dbi_poweron_reset);
|
||||
* Zero if the controller was reset, 1 if the display was already on, or a
|
||||
* negative error code.
|
||||
*/
|
||||
int mipi_dbi_poweron_conditional_reset(struct mipi_dbi *dbidev)
|
||||
int mipi_dbi_poweron_conditional_reset(struct mipi_dbi_dev *dbidev)
|
||||
{
|
||||
return mipi_dbi_poweron_reset_conditional(dbidev, true);
|
||||
}
|
||||
@ -1066,7 +1066,7 @@ static int mipi_dbi_typec3_command(struct mipi_dbi *dbi, u8 *cmd,
|
||||
* @dc: D/C gpio (optional)
|
||||
*
|
||||
* This function sets &mipi_dbi->command, enables &mipi_dbi->read_commands for the
|
||||
* usual read commands. It should be followed by a call to mipi_dbi_init() or
|
||||
* usual read commands. It should be followed by a call to mipi_dbi_dev_init() or
|
||||
* a driver-specific init.
|
||||
*
|
||||
* If @dc is set, a Type C Option 3 interface is assumed, if not
|
||||
@ -1183,13 +1183,13 @@ static ssize_t mipi_dbi_debugfs_command_write(struct file *file,
|
||||
size_t count, loff_t *ppos)
|
||||
{
|
||||
struct seq_file *m = file->private_data;
|
||||
struct mipi_dbi *mipi = m->private;
|
||||
struct mipi_dbi_dev *dbidev = m->private;
|
||||
u8 val, cmd = 0, parameters[64];
|
||||
char *buf, *pos, *token;
|
||||
unsigned int i;
|
||||
int ret, idx;
|
||||
|
||||
if (!drm_dev_enter(&mipi->drm, &idx))
|
||||
if (!drm_dev_enter(&dbidev->drm, &idx))
|
||||
return -ENODEV;
|
||||
|
||||
buf = memdup_user_nul(ubuf, count);
|
||||
@ -1228,7 +1228,7 @@ static ssize_t mipi_dbi_debugfs_command_write(struct file *file,
|
||||
}
|
||||
}
|
||||
|
||||
ret = mipi_dbi_command_buf(mipi, cmd, parameters, i);
|
||||
ret = mipi_dbi_command_buf(&dbidev->dbi, cmd, parameters, i);
|
||||
|
||||
err_free:
|
||||
kfree(buf);
|
||||
@ -1240,16 +1240,17 @@ err_exit:
|
||||
|
||||
static int mipi_dbi_debugfs_command_show(struct seq_file *m, void *unused)
|
||||
{
|
||||
struct mipi_dbi *mipi = m->private;
|
||||
struct mipi_dbi_dev *dbidev = m->private;
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
u8 cmd, val[4];
|
||||
int ret, idx;
|
||||
size_t len;
|
||||
|
||||
if (!drm_dev_enter(&mipi->drm, &idx))
|
||||
if (!drm_dev_enter(&dbidev->drm, &idx))
|
||||
return -ENODEV;
|
||||
|
||||
for (cmd = 0; cmd < 255; cmd++) {
|
||||
if (!mipi_dbi_command_is_read(mipi, cmd))
|
||||
if (!mipi_dbi_command_is_read(dbi, cmd))
|
||||
continue;
|
||||
|
||||
switch (cmd) {
|
||||
@ -1269,7 +1270,7 @@ static int mipi_dbi_debugfs_command_show(struct seq_file *m, void *unused)
|
||||
}
|
||||
|
||||
seq_printf(m, "%02x: ", cmd);
|
||||
ret = mipi_dbi_command_buf(mipi, cmd, val, len);
|
||||
ret = mipi_dbi_command_buf(dbi, cmd, val, len);
|
||||
if (ret) {
|
||||
seq_puts(m, "XX\n");
|
||||
continue;
|
||||
@ -1311,12 +1312,12 @@ static const struct file_operations mipi_dbi_debugfs_command_fops = {
|
||||
*/
|
||||
int mipi_dbi_debugfs_init(struct drm_minor *minor)
|
||||
{
|
||||
struct mipi_dbi *mipi = drm_to_mipi_dbi(minor->dev);
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(minor->dev);
|
||||
umode_t mode = S_IFREG | S_IWUSR;
|
||||
|
||||
if (mipi->read_commands)
|
||||
if (dbidev->dbi.read_commands)
|
||||
mode |= S_IRUGO;
|
||||
debugfs_create_file("command", mode, minor->debugfs_root, mipi,
|
||||
debugfs_create_file("command", mode, minor->debugfs_root, dbidev,
|
||||
&mipi_dbi_debugfs_command_fops);
|
||||
|
||||
return 0;
|
||||
|
@ -114,8 +114,8 @@ static int st7586_buf_copy(void *dst, struct drm_framebuffer *fb,
|
||||
|
||||
static void st7586_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
|
||||
{
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(fb->dev);
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev);
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
int start, end, idx, ret = 0;
|
||||
|
||||
if (!dbidev->enabled)
|
||||
@ -177,9 +177,9 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
|
||||
struct drm_crtc_state *crtc_state,
|
||||
struct drm_plane_state *plane_state)
|
||||
{
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev);
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
|
||||
struct drm_framebuffer *fb = plane_state->fb;
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
struct drm_rect rect = {
|
||||
.x1 = 0,
|
||||
.x2 = fb->width,
|
||||
@ -255,7 +255,7 @@ out_exit:
|
||||
|
||||
static void st7586_pipe_disable(struct drm_simple_display_pipe *pipe)
|
||||
{
|
||||
struct mipi_dbi *mipi = drm_to_mipi_dbi(pipe->crtc.dev);
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
|
||||
|
||||
/*
|
||||
* This callback is not protected by drm_dev_enter/exit since we want to
|
||||
@ -266,11 +266,11 @@ static void st7586_pipe_disable(struct drm_simple_display_pipe *pipe)
|
||||
|
||||
DRM_DEBUG_KMS("\n");
|
||||
|
||||
if (!mipi->enabled)
|
||||
if (!dbidev->enabled)
|
||||
return;
|
||||
|
||||
mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_OFF);
|
||||
mipi->enabled = false;
|
||||
mipi_dbi_command(&dbidev->dbi, MIPI_DCS_SET_DISPLAY_OFF);
|
||||
dbidev->enabled = false;
|
||||
}
|
||||
|
||||
static const u32 st7586_formats[] = {
|
||||
@ -318,7 +318,7 @@ MODULE_DEVICE_TABLE(spi, st7586_id);
|
||||
static int st7586_probe(struct spi_device *spi)
|
||||
{
|
||||
struct device *dev = &spi->dev;
|
||||
struct mipi_dbi *dbidev;
|
||||
struct mipi_dbi_dev *dbidev;
|
||||
struct drm_device *drm;
|
||||
struct mipi_dbi *dbi;
|
||||
struct gpio_desc *a0;
|
||||
@ -330,7 +330,7 @@ static int st7586_probe(struct spi_device *spi)
|
||||
if (!dbidev)
|
||||
return -ENOMEM;
|
||||
|
||||
dbi = dbidev;
|
||||
dbi = &dbidev->dbi;
|
||||
drm = &dbidev->drm;
|
||||
ret = devm_drm_dev_init(dev, drm, &st7586_driver);
|
||||
if (ret) {
|
||||
@ -363,9 +363,9 @@ static int st7586_probe(struct spi_device *spi)
|
||||
/* Cannot read from this controller via SPI */
|
||||
dbi->read_commands = NULL;
|
||||
|
||||
ret = mipi_dbi_init_with_formats(dbidev, &st7586_pipe_funcs,
|
||||
st7586_formats, ARRAY_SIZE(st7586_formats),
|
||||
&st7586_mode, rotation, bufsize);
|
||||
ret = mipi_dbi_dev_init_with_formats(dbidev, &st7586_pipe_funcs,
|
||||
st7586_formats, ARRAY_SIZE(st7586_formats),
|
||||
&st7586_mode, rotation, bufsize);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -42,8 +42,8 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe,
|
||||
struct drm_crtc_state *crtc_state,
|
||||
struct drm_plane_state *plane_state)
|
||||
{
|
||||
struct mipi_dbi *dbidev = drm_to_mipi_dbi(pipe->crtc.dev);
|
||||
struct mipi_dbi *dbi = dbidev;
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
|
||||
struct mipi_dbi *dbi = &dbidev->dbi;
|
||||
int ret, idx;
|
||||
u8 addr_mode;
|
||||
|
||||
@ -150,7 +150,7 @@ MODULE_DEVICE_TABLE(spi, st7735r_id);
|
||||
static int st7735r_probe(struct spi_device *spi)
|
||||
{
|
||||
struct device *dev = &spi->dev;
|
||||
struct mipi_dbi *dbidev;
|
||||
struct mipi_dbi_dev *dbidev;
|
||||
struct drm_device *drm;
|
||||
struct mipi_dbi *dbi;
|
||||
struct gpio_desc *dc;
|
||||
@ -161,7 +161,7 @@ static int st7735r_probe(struct spi_device *spi)
|
||||
if (!dbidev)
|
||||
return -ENOMEM;
|
||||
|
||||
dbi = dbidev;
|
||||
dbi = &dbidev->dbi;
|
||||
drm = &dbidev->drm;
|
||||
ret = devm_drm_dev_init(dev, drm, &st7735r_driver);
|
||||
if (ret) {
|
||||
@ -196,7 +196,7 @@ static int st7735r_probe(struct spi_device *spi)
|
||||
/* Cannot read from Adafruit 1.8" display via SPI */
|
||||
dbi->read_commands = NULL;
|
||||
|
||||
ret = mipi_dbi_init(dbidev, &jd_t18003_t01_pipe_funcs, &jd_t18003_t01_mode, rotation);
|
||||
ret = mipi_dbi_dev_init(dbidev, &jd_t18003_t01_pipe_funcs, &jd_t18003_t01_mode, rotation);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -18,24 +18,62 @@ struct gpio_desc;
|
||||
struct regulator;
|
||||
|
||||
/**
|
||||
* struct mipi_dbi - MIPI DBI controller
|
||||
* @spi: SPI device
|
||||
* @enabled: Pipeline is enabled
|
||||
* @cmdlock: Command lock
|
||||
* @command: Bus specific callback executing commands.
|
||||
* @read_commands: Array of read commands terminated by a zero entry.
|
||||
* Reading is disabled if this is NULL.
|
||||
* @dc: Optional D/C gpio.
|
||||
* @tx_buf: Buffer used for transfer (copy clip rect area)
|
||||
* @tx_buf9: Buffer used for Option 1 9-bit conversion
|
||||
* @tx_buf9_len: Size of tx_buf9.
|
||||
* @swap_bytes: Swap bytes in buffer before transfer
|
||||
* @reset: Optional reset gpio
|
||||
* @rotation: initial rotation in degrees Counter Clock Wise
|
||||
* @backlight: backlight device (optional)
|
||||
* @regulator: power regulator (optional)
|
||||
* struct mipi_dbi - MIPI DBI interface
|
||||
*/
|
||||
struct mipi_dbi {
|
||||
/**
|
||||
* @cmdlock: Command lock
|
||||
*/
|
||||
struct mutex cmdlock;
|
||||
|
||||
/**
|
||||
* @command: Bus specific callback executing commands.
|
||||
*/
|
||||
int (*command)(struct mipi_dbi *dbi, u8 *cmd, u8 *param, size_t num);
|
||||
|
||||
/**
|
||||
* @read_commands: Array of read commands terminated by a zero entry.
|
||||
* Reading is disabled if this is NULL.
|
||||
*/
|
||||
const u8 *read_commands;
|
||||
|
||||
/**
|
||||
* @swap_bytes: Swap bytes in buffer before transfer
|
||||
*/
|
||||
bool swap_bytes;
|
||||
|
||||
/**
|
||||
* @reset: Optional reset gpio
|
||||
*/
|
||||
struct gpio_desc *reset;
|
||||
|
||||
/* Type C specific */
|
||||
|
||||
/**
|
||||
* @spi: SPI device
|
||||
*/
|
||||
struct spi_device *spi;
|
||||
|
||||
/**
|
||||
* @dc: Optional D/C gpio.
|
||||
*/
|
||||
struct gpio_desc *dc;
|
||||
|
||||
/**
|
||||
* @tx_buf9: Buffer used for Option 1 9-bit conversion
|
||||
*/
|
||||
void *tx_buf9;
|
||||
|
||||
/**
|
||||
* @tx_buf9_len: Size of tx_buf9.
|
||||
*/
|
||||
size_t tx_buf9_len;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mipi_dbi_dev - MIPI DBI device
|
||||
*/
|
||||
struct mipi_dbi_dev {
|
||||
/**
|
||||
* @drm: DRM device
|
||||
*/
|
||||
@ -56,48 +94,63 @@ struct mipi_dbi {
|
||||
*/
|
||||
struct drm_display_mode mode;
|
||||
|
||||
struct spi_device *spi;
|
||||
/**
|
||||
* @enabled: Pipeline is enabled
|
||||
*/
|
||||
bool enabled;
|
||||
struct mutex cmdlock;
|
||||
int (*command)(struct mipi_dbi *dbi, u8 *cmd, u8 *param, size_t num);
|
||||
const u8 *read_commands;
|
||||
struct gpio_desc *dc;
|
||||
|
||||
/**
|
||||
* @tx_buf: Buffer used for transfer (copy clip rect area)
|
||||
*/
|
||||
u16 *tx_buf;
|
||||
void *tx_buf9;
|
||||
size_t tx_buf9_len;
|
||||
bool swap_bytes;
|
||||
struct gpio_desc *reset;
|
||||
|
||||
/**
|
||||
* @rotation: initial rotation in degrees Counter Clock Wise
|
||||
*/
|
||||
unsigned int rotation;
|
||||
|
||||
/**
|
||||
* @backlight: backlight device (optional)
|
||||
*/
|
||||
struct backlight_device *backlight;
|
||||
|
||||
/**
|
||||
* @regulator: power regulator (optional)
|
||||
*/
|
||||
struct regulator *regulator;
|
||||
|
||||
/**
|
||||
* @dbi: MIPI DBI interface
|
||||
*/
|
||||
struct mipi_dbi dbi;
|
||||
};
|
||||
|
||||
static inline struct mipi_dbi *drm_to_mipi_dbi(struct drm_device *drm)
|
||||
static inline struct mipi_dbi_dev *drm_to_mipi_dbi_dev(struct drm_device *drm)
|
||||
{
|
||||
return container_of(drm, struct mipi_dbi, drm);
|
||||
return container_of(drm, struct mipi_dbi_dev, drm);
|
||||
}
|
||||
|
||||
int mipi_dbi_spi_init(struct spi_device *spi, struct mipi_dbi *dbi,
|
||||
struct gpio_desc *dc);
|
||||
int mipi_dbi_init_with_formats(struct mipi_dbi *dbidev,
|
||||
const struct drm_simple_display_pipe_funcs *funcs,
|
||||
const uint32_t *formats, unsigned int format_count,
|
||||
const struct drm_display_mode *mode,
|
||||
unsigned int rotation, size_t tx_buf_size);
|
||||
int mipi_dbi_init(struct mipi_dbi *dbidev,
|
||||
const struct drm_simple_display_pipe_funcs *funcs,
|
||||
const struct drm_display_mode *mode, unsigned int rotation);
|
||||
int mipi_dbi_dev_init_with_formats(struct mipi_dbi_dev *dbidev,
|
||||
const struct drm_simple_display_pipe_funcs *funcs,
|
||||
const uint32_t *formats, unsigned int format_count,
|
||||
const struct drm_display_mode *mode,
|
||||
unsigned int rotation, size_t tx_buf_size);
|
||||
int mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev,
|
||||
const struct drm_simple_display_pipe_funcs *funcs,
|
||||
const struct drm_display_mode *mode, unsigned int rotation);
|
||||
void mipi_dbi_release(struct drm_device *drm);
|
||||
void mipi_dbi_pipe_update(struct drm_simple_display_pipe *pipe,
|
||||
struct drm_plane_state *old_state);
|
||||
void mipi_dbi_enable_flush(struct mipi_dbi *dbidev,
|
||||
void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev,
|
||||
struct drm_crtc_state *crtc_state,
|
||||
struct drm_plane_state *plan_state);
|
||||
void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe);
|
||||
void mipi_dbi_hw_reset(struct mipi_dbi *dbi);
|
||||
bool mipi_dbi_display_is_on(struct mipi_dbi *dbi);
|
||||
int mipi_dbi_poweron_reset(struct mipi_dbi *dbidev);
|
||||
int mipi_dbi_poweron_conditional_reset(struct mipi_dbi *dbidev);
|
||||
int mipi_dbi_poweron_reset(struct mipi_dbi_dev *dbidev);
|
||||
int mipi_dbi_poweron_conditional_reset(struct mipi_dbi_dev *dbidev);
|
||||
|
||||
u32 mipi_dbi_spi_cmd_max_speed(struct spi_device *spi, size_t len);
|
||||
int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz,
|
||||
|
Loading…
Reference in New Issue
Block a user