linux/drivers/gpu/drm/tiny/st7586.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * DRM driver for Sitronix ST7586 panels
 *
 * Copyright 2017 David Lechner <[email protected]>
 */

#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/property.h>
#include <linux/spi/spi.h>
#include <video/mipi_display.h>

#include <drm/drm_atomic_helper.h>
#include <drm/drm_damage_helper.h>
#include <drm/drm_drv.h>
#include <drm/drm_fb_dma_helper.h>
#include <drm/drm_fbdev_dma.h>
#include <drm/drm_format_helper.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_atomic_helper.h>
#include <drm/drm_gem_dma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_managed.h>
#include <drm/drm_mipi_dbi.h>
#include <drm/drm_rect.h>

/* controller-specific commands */
#define ST7586_DISP_MODE_GRAY
#define ST7586_DISP_MODE_MONO
#define ST7586_ENABLE_DDRAM
#define ST7586_SET_DISP_DUTY
#define ST7586_SET_PART_DISP
#define ST7586_SET_NLINE_INV
#define ST7586_SET_VOP
#define ST7586_SET_BIAS_SYSTEM
#define ST7586_SET_BOOST_LEVEL
#define ST7586_SET_VOP_OFFSET
#define ST7586_ENABLE_ANALOG
#define ST7586_AUTO_READ_CTRL
#define ST7586_OTP_RW_CTRL
#define ST7586_OTP_CTRL_OUT
#define ST7586_OTP_READ

#define ST7586_DISP_CTRL_MX
#define ST7586_DISP_CTRL_MY

/*
 * The ST7586 controller has an unusual pixel format where 2bpp grayscale is
 * packed 3 pixels per byte with the first two pixels using 3 bits and the 3rd
 * pixel using only 2 bits.
 *
 * |  D7  |  D6  |  D5  ||      |      || 2bpp |
 * | (D4) | (D3) | (D2) ||  D1  |  D0  || GRAY |
 * +------+------+------++------+------++------+
 * |  1   |  1   |  1   ||  1   |  1   || 0  0 | black
 * |  1   |  0   |  0   ||  1   |  0   || 0  1 | dark gray
 * |  0   |  1   |  0   ||  0   |  1   || 1  0 | light gray
 * |  0   |  0   |  0   ||  0   |  0   || 1  1 | white
 */

static const u8 st7586_lookup[] =;

static void st7586_xrgb8888_to_gray332(u8 *dst, void *vaddr,
				       struct drm_framebuffer *fb,
				       struct drm_rect *clip,
				       struct drm_format_conv_state *fmtcnv_state)
{}

static int st7586_buf_copy(void *dst, struct iosys_map *src, struct drm_framebuffer *fb,
			   struct drm_rect *clip, struct drm_format_conv_state *fmtcnv_state)
{}

static void st7586_fb_dirty(struct iosys_map *src, struct drm_framebuffer *fb,
			    struct drm_rect *rect, struct drm_format_conv_state *fmtcnv_state)
{}

static void st7586_pipe_update(struct drm_simple_display_pipe *pipe,
			       struct drm_plane_state *old_state)
{}

static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
			       struct drm_crtc_state *crtc_state,
			       struct drm_plane_state *plane_state)
{}

static void st7586_pipe_disable(struct drm_simple_display_pipe *pipe)
{}

static const u32 st7586_formats[] =;

static const struct drm_simple_display_pipe_funcs st7586_pipe_funcs =;

static const struct drm_display_mode st7586_mode =;

DEFINE_DRM_GEM_DMA_FOPS(st7586_fops);

static const struct drm_driver st7586_driver =;

static const struct of_device_id st7586_of_match[] =;
MODULE_DEVICE_TABLE(of, st7586_of_match);

static const struct spi_device_id st7586_id[] =;
MODULE_DEVICE_TABLE(spi, st7586_id);

static int st7586_probe(struct spi_device *spi)
{}

static void st7586_remove(struct spi_device *spi)
{}

static void st7586_shutdown(struct spi_device *spi)
{}

static struct spi_driver st7586_spi_driver =;
module_spi_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();