#include <linux/backlight.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/media-bus-format.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/regulator/consumer.h>
#include <video/mipi_display.h>
#include <video/of_videomode.h>
#include <video/videomode.h>
#include <drm/drm_crtc.h>
#include <drm/drm_mipi_dsi.h>
#include <drm/drm_panel.h>
#define COL_FMT_16BPP …
#define COL_FMT_18BPP …
#define COL_FMT_24BPP …
#define WRMAUCCTR …
struct cmd_set_entry { … };
static const struct cmd_set_entry manufacturer_cmd_set[] = …;
static const u32 rad_bus_formats[] = …;
static const u32 rad_bus_flags = …;
struct rad_panel { … };
static const struct drm_display_mode default_mode = …;
static inline struct rad_panel *to_rad_panel(struct drm_panel *panel)
{ … }
static int rad_panel_push_cmd_list(struct mipi_dsi_device *dsi)
{
size_t i;
size_t count = ARRAY_SIZE(manufacturer_cmd_set);
int ret = 0;
for (i = 0; i < count; i++) {
const struct cmd_set_entry *entry = &manufacturer_cmd_set[i];
u8 buffer[2] = { entry->cmd, entry->param };
ret = mipi_dsi_generic_write(dsi, &buffer, sizeof(buffer));
if (ret < 0)
return ret;
}
return ret;
};
static int color_format_from_dsi_format(enum mipi_dsi_pixel_format format)
{
switch (format) {
case MIPI_DSI_FMT_RGB565:
return COL_FMT_16BPP;
case MIPI_DSI_FMT_RGB666:
case MIPI_DSI_FMT_RGB666_PACKED:
return COL_FMT_18BPP;
case MIPI_DSI_FMT_RGB888:
return COL_FMT_24BPP;
default:
return COL_FMT_24BPP;
}
};
static int rad_panel_prepare(struct drm_panel *panel)
{ … }
static int rad_panel_unprepare(struct drm_panel *panel)
{ … }
static int rad_panel_enable(struct drm_panel *panel)
{ … }
static int rad_panel_disable(struct drm_panel *panel)
{ … }
static int rad_panel_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{ … }
static int rad_bl_get_brightness(struct backlight_device *bl)
{ … }
static int rad_bl_update_status(struct backlight_device *bl)
{ … }
static const struct backlight_ops rad_bl_ops = …;
static const struct drm_panel_funcs rad_panel_funcs = …;
static const char * const rad_supply_names[] = …;
static int rad_init_regulators(struct rad_panel *rad)
{
struct device *dev = &rad->dsi->dev;
int i;
rad->num_supplies = ARRAY_SIZE(rad_supply_names);
rad->supplies = devm_kcalloc(dev, rad->num_supplies,
sizeof(*rad->supplies), GFP_KERNEL);
if (!rad->supplies)
return -ENOMEM;
for (i = 0; i < rad->num_supplies; i++)
rad->supplies[i].supply = rad_supply_names[i];
return devm_regulator_bulk_get(dev, rad->num_supplies, rad->supplies);
};
static int rad_panel_probe(struct mipi_dsi_device *dsi)
{ … }
static void rad_panel_remove(struct mipi_dsi_device *dsi)
{ … }
static const struct of_device_id rad_of_match[] = …;
MODULE_DEVICE_TABLE(of, rad_of_match);
static struct mipi_dsi_driver rad_panel_driver = …;
module_mipi_dsi_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;