linux/drivers/gpu/drm/solomon/ssd130x.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * DRM driver for Solomon SSD13xx OLED displays
 *
 * Copyright 2022 Red Hat Inc.
 * Author: Javier Martinez Canillas <[email protected]>
 *
 * Based on drivers/video/fbdev/ssd1307fb.c
 * Copyright 2012 Free Electrons
 */

#include <linux/backlight.h>
#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/property.h>
#include <linux/pwm.h>
#include <linux/regulator/consumer.h>

#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_damage_helper.h>
#include <drm/drm_edid.h>
#include <drm/drm_fbdev_shmem.h>
#include <drm/drm_format_helper.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_atomic_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_gem_shmem_helper.h>
#include <drm/drm_managed.h>
#include <drm/drm_modes.h>
#include <drm/drm_rect.h>
#include <drm/drm_probe_helper.h>

#include "ssd130x.h"

#define DRIVER_NAME
#define DRIVER_DESC
#define DRIVER_DATE
#define DRIVER_MAJOR
#define DRIVER_MINOR

#define SSD130X_PAGE_HEIGHT

#define SSD132X_SEGMENT_WIDTH

/* ssd13xx commands */
#define SSD13XX_CONTRAST
#define SSD13XX_SET_SEG_REMAP
#define SSD13XX_SET_MULTIPLEX_RATIO
#define SSD13XX_DISPLAY_OFF
#define SSD13XX_DISPLAY_ON

#define SSD13XX_SET_SEG_REMAP_MASK
#define SSD13XX_SET_SEG_REMAP_SET(val)

/* ssd130x commands */
#define SSD130X_PAGE_COL_START_LOW
#define SSD130X_PAGE_COL_START_HIGH
#define SSD130X_SET_ADDRESS_MODE
#define SSD130X_SET_COL_RANGE
#define SSD130X_SET_PAGE_RANGE
#define SSD130X_SET_LOOKUP_TABLE
#define SSD130X_CHARGE_PUMP
#define SSD130X_START_PAGE_ADDRESS
#define SSD130X_SET_COM_SCAN_DIR
#define SSD130X_SET_DISPLAY_OFFSET
#define SSD130X_SET_CLOCK_FREQ
#define SSD130X_SET_AREA_COLOR_MODE
#define SSD130X_SET_PRECHARGE_PERIOD
#define SSD130X_SET_COM_PINS_CONFIG
#define SSD130X_SET_VCOMH

/* ssd130x commands accessors */
#define SSD130X_PAGE_COL_START_MASK
#define SSD130X_PAGE_COL_START_HIGH_SET(val)
#define SSD130X_PAGE_COL_START_LOW_SET(val)
#define SSD130X_START_PAGE_ADDRESS_MASK
#define SSD130X_START_PAGE_ADDRESS_SET(val)
#define SSD130X_SET_COM_SCAN_DIR_MASK
#define SSD130X_SET_COM_SCAN_DIR_SET(val)
#define SSD130X_SET_CLOCK_DIV_MASK
#define SSD130X_SET_CLOCK_DIV_SET(val)
#define SSD130X_SET_CLOCK_FREQ_MASK
#define SSD130X_SET_CLOCK_FREQ_SET(val)
#define SSD130X_SET_PRECHARGE_PERIOD1_MASK
#define SSD130X_SET_PRECHARGE_PERIOD1_SET(val)
#define SSD130X_SET_PRECHARGE_PERIOD2_MASK
#define SSD130X_SET_PRECHARGE_PERIOD2_SET(val)
#define SSD130X_SET_COM_PINS_CONFIG1_MASK
#define SSD130X_SET_COM_PINS_CONFIG1_SET(val)
#define SSD130X_SET_COM_PINS_CONFIG2_MASK
#define SSD130X_SET_COM_PINS_CONFIG2_SET(val)

#define SSD130X_SET_ADDRESS_MODE_HORIZONTAL
#define SSD130X_SET_ADDRESS_MODE_VERTICAL
#define SSD130X_SET_ADDRESS_MODE_PAGE

#define SSD130X_SET_AREA_COLOR_MODE_ENABLE
#define SSD130X_SET_AREA_COLOR_MODE_LOW_POWER

/* ssd132x commands */
#define SSD132X_SET_COL_RANGE
#define SSD132X_SET_DEACTIVATE_SCROLL
#define SSD132X_SET_ROW_RANGE
#define SSD132X_SET_DISPLAY_START
#define SSD132X_SET_DISPLAY_OFFSET
#define SSD132X_SET_DISPLAY_NORMAL
#define SSD132X_SET_FUNCTION_SELECT_A
#define SSD132X_SET_PHASE_LENGTH
#define SSD132X_SET_CLOCK_FREQ
#define SSD132X_SET_GPIO
#define SSD132X_SET_PRECHARGE_PERIOD
#define SSD132X_SET_GRAY_SCALE_TABLE
#define SSD132X_SELECT_DEFAULT_TABLE
#define SSD132X_SET_PRECHARGE_VOLTAGE
#define SSD130X_SET_VCOMH_VOLTAGE
#define SSD132X_SET_FUNCTION_SELECT_B

/* ssd133x commands */
#define SSD133X_SET_COL_RANGE
#define SSD133X_SET_ROW_RANGE
#define SSD133X_CONTRAST_A
#define SSD133X_CONTRAST_B
#define SSD133X_CONTRAST_C
#define SSD133X_SET_MASTER_CURRENT
#define SSD132X_SET_PRECHARGE_A
#define SSD132X_SET_PRECHARGE_B
#define SSD132X_SET_PRECHARGE_C
#define SSD133X_SET_DISPLAY_START
#define SSD133X_SET_DISPLAY_OFFSET
#define SSD133X_SET_DISPLAY_NORMAL
#define SSD133X_SET_MASTER_CONFIG
#define SSD133X_POWER_SAVE_MODE
#define SSD133X_PHASES_PERIOD
#define SSD133X_SET_CLOCK_FREQ
#define SSD133X_SET_PRECHARGE_VOLTAGE
#define SSD133X_SET_VCOMH_VOLTAGE

#define MAX_CONTRAST

const struct ssd130x_deviceinfo ssd130x_variants[] =;
EXPORT_SYMBOL_NS_GPL();

struct ssd130x_crtc_state {};

struct ssd130x_plane_state {};

static inline struct ssd130x_crtc_state *to_ssd130x_crtc_state(struct drm_crtc_state *state)
{}

static inline struct ssd130x_plane_state *to_ssd130x_plane_state(struct drm_plane_state *state)
{}

static inline struct ssd130x_device *drm_to_ssd130x(struct drm_device *drm)
{}

/*
 * Helper to write data (SSD13XX_DATA) to the device.
 */
static int ssd130x_write_data(struct ssd130x_device *ssd130x, u8 *values, int count)
{}

/*
 * Helper to write command (SSD13XX_COMMAND). The fist variadic argument
 * is the command to write and the following are the command options.
 *
 * Note that the ssd13xx protocol requires each command and option to be
 * written as a SSD13XX_COMMAND device register value. That is why a call
 * to regmap_write(..., SSD13XX_COMMAND, ...) is done for each argument.
 */
static int ssd130x_write_cmd(struct ssd130x_device *ssd130x, int count,
			     /* u8 cmd, u8 option, ... */...)
{}

/* Set address range for horizontal/vertical addressing modes */
static int ssd130x_set_col_range(struct ssd130x_device *ssd130x,
				 u8 col_start, u8 cols)
{}

static int ssd130x_set_page_range(struct ssd130x_device *ssd130x,
				  u8 page_start, u8 pages)
{}

/* Set page and column start address for page addressing mode */
static int ssd130x_set_page_pos(struct ssd130x_device *ssd130x,
				u8 page_start, u8 col_start)
{}

static int ssd130x_pwm_enable(struct ssd130x_device *ssd130x)
{}

static void ssd130x_reset(struct ssd130x_device *ssd130x)
{}

static int ssd130x_power_on(struct ssd130x_device *ssd130x)
{}

static void ssd130x_power_off(struct ssd130x_device *ssd130x)
{}

static int ssd130x_init(struct ssd130x_device *ssd130x)
{}

static int ssd132x_init(struct ssd130x_device *ssd130x)
{}

static int ssd133x_init(struct ssd130x_device *ssd130x)
{}

static int ssd130x_update_rect(struct ssd130x_device *ssd130x,
			       struct drm_rect *rect, u8 *buf,
			       u8 *data_array)
{}

static int ssd132x_update_rect(struct ssd130x_device *ssd130x,
			       struct drm_rect *rect, u8 *buf,
			       u8 *data_array)
{}

static int ssd133x_update_rect(struct ssd130x_device *ssd130x,
			       struct drm_rect *rect, u8 *data_array,
			       unsigned int pitch)
{}

static void ssd130x_clear_screen(struct ssd130x_device *ssd130x, u8 *data_array)
{}

static void ssd132x_clear_screen(struct ssd130x_device *ssd130x, u8 *data_array)
{}

static void ssd133x_clear_screen(struct ssd130x_device *ssd130x, u8 *data_array)
{}

static int ssd130x_fb_blit_rect(struct drm_framebuffer *fb,
				const struct iosys_map *vmap,
				struct drm_rect *rect,
				u8 *buf, u8 *data_array,
				struct drm_format_conv_state *fmtcnv_state)
{}

static int ssd132x_fb_blit_rect(struct drm_framebuffer *fb,
				const struct iosys_map *vmap,
				struct drm_rect *rect, u8 *buf,
				u8 *data_array,
				struct drm_format_conv_state *fmtcnv_state)
{}

static int ssd133x_fb_blit_rect(struct drm_framebuffer *fb,
				const struct iosys_map *vmap,
				struct drm_rect *rect, u8 *data_array,
				struct drm_format_conv_state *fmtcnv_state)
{}

static int ssd130x_primary_plane_atomic_check(struct drm_plane *plane,
					      struct drm_atomic_state *state)
{}

static int ssd132x_primary_plane_atomic_check(struct drm_plane *plane,
					      struct drm_atomic_state *state)
{}

static int ssd133x_primary_plane_atomic_check(struct drm_plane *plane,
					      struct drm_atomic_state *state)
{}

static void ssd130x_primary_plane_atomic_update(struct drm_plane *plane,
						struct drm_atomic_state *state)
{}

static void ssd132x_primary_plane_atomic_update(struct drm_plane *plane,
						struct drm_atomic_state *state)
{}

static void ssd133x_primary_plane_atomic_update(struct drm_plane *plane,
						struct drm_atomic_state *state)
{}

static void ssd130x_primary_plane_atomic_disable(struct drm_plane *plane,
						 struct drm_atomic_state *state)
{}

static void ssd132x_primary_plane_atomic_disable(struct drm_plane *plane,
						 struct drm_atomic_state *state)
{}

static void ssd133x_primary_plane_atomic_disable(struct drm_plane *plane,
						 struct drm_atomic_state *state)
{}

/* Called during init to allocate the plane's atomic state. */
static void ssd130x_primary_plane_reset(struct drm_plane *plane)
{}

static struct drm_plane_state *ssd130x_primary_plane_duplicate_state(struct drm_plane *plane)
{}

static void ssd130x_primary_plane_destroy_state(struct drm_plane *plane,
						struct drm_plane_state *state)
{}

static const struct drm_plane_helper_funcs ssd130x_primary_plane_helper_funcs[] =;

static const struct drm_plane_funcs ssd130x_primary_plane_funcs =;

static enum drm_mode_status ssd130x_crtc_mode_valid(struct drm_crtc *crtc,
						    const struct drm_display_mode *mode)
{}

static int ssd130x_crtc_atomic_check(struct drm_crtc *crtc,
				     struct drm_atomic_state *state)
{}

static int ssd132x_crtc_atomic_check(struct drm_crtc *crtc,
				     struct drm_atomic_state *state)
{}

static int ssd133x_crtc_atomic_check(struct drm_crtc *crtc,
				     struct drm_atomic_state *state)
{}

/* Called during init to allocate the CRTC's atomic state. */
static void ssd130x_crtc_reset(struct drm_crtc *crtc)
{}

static struct drm_crtc_state *ssd130x_crtc_duplicate_state(struct drm_crtc *crtc)
{}

static void ssd130x_crtc_destroy_state(struct drm_crtc *crtc,
				       struct drm_crtc_state *state)
{}

/*
 * The CRTC is always enabled. Screen updates are performed by
 * the primary plane's atomic_update function. Disabling clears
 * the screen in the primary plane's atomic_disable function.
 */
static const struct drm_crtc_helper_funcs ssd130x_crtc_helper_funcs[] =;

static const struct drm_crtc_funcs ssd130x_crtc_funcs =;

static void ssd130x_encoder_atomic_enable(struct drm_encoder *encoder,
					  struct drm_atomic_state *state)
{}

static void ssd132x_encoder_atomic_enable(struct drm_encoder *encoder,
					  struct drm_atomic_state *state)
{}

static void ssd133x_encoder_atomic_enable(struct drm_encoder *encoder,
					  struct drm_atomic_state *state)
{}

static void ssd130x_encoder_atomic_disable(struct drm_encoder *encoder,
					   struct drm_atomic_state *state)
{}

static const struct drm_encoder_helper_funcs ssd130x_encoder_helper_funcs[] =;

static const struct drm_encoder_funcs ssd130x_encoder_funcs =;

static int ssd130x_connector_get_modes(struct drm_connector *connector)
{}

static const struct drm_connector_helper_funcs ssd130x_connector_helper_funcs =;

static const struct drm_connector_funcs ssd130x_connector_funcs =;

static const struct drm_mode_config_funcs ssd130x_mode_config_funcs =;

static const uint32_t ssd130x_formats[] =;

DEFINE_DRM_GEM_FOPS(ssd130x_fops);

static const struct drm_driver ssd130x_drm_driver =;

static int ssd130x_update_bl(struct backlight_device *bdev)
{}

static const struct backlight_ops ssd130xfb_bl_ops =;

static void ssd130x_parse_properties(struct ssd130x_device *ssd130x)
{}

static int ssd130x_init_modeset(struct ssd130x_device *ssd130x)
{}

static int ssd130x_get_resources(struct ssd130x_device *ssd130x)
{}

struct ssd130x_device *ssd130x_probe(struct device *dev, struct regmap *regmap)
{}
EXPORT_SYMBOL_GPL();

void ssd130x_remove(struct ssd130x_device *ssd130x)
{}
EXPORT_SYMBOL_GPL();

void ssd130x_shutdown(struct ssd130x_device *ssd130x)
{}
EXPORT_SYMBOL_GPL();

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