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

// SPDX-License-Identifier: GPL-2.0-only

#include <linux/clk.h>
#include <linux/of_clk.h>
#include <linux/minmax.h>
#include <linux/of_address.h>
#include <linux/platform_data/simplefb.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/regulator/consumer.h>

#include <drm/drm_aperture.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_state_helper.h>
#include <drm/drm_connector.h>
#include <drm/drm_crtc_helper.h>
#include <drm/drm_damage_helper.h>
#include <drm/drm_device.h>
#include <drm/drm_drv.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_modeset_helper_vtables.h>
#include <drm/drm_panic.h>
#include <drm/drm_probe_helper.h>

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

/*
 * Helpers for simplefb
 */

static int
simplefb_get_validated_int(struct drm_device *dev, const char *name,
			   uint32_t value)
{}

static int
simplefb_get_validated_int0(struct drm_device *dev, const char *name,
			    uint32_t value)
{}

static const struct drm_format_info *
simplefb_get_validated_format(struct drm_device *dev, const char *format_name)
{}

static int
simplefb_get_width_pd(struct drm_device *dev,
		      const struct simplefb_platform_data *pd)
{}

static int
simplefb_get_height_pd(struct drm_device *dev,
		       const struct simplefb_platform_data *pd)
{}

static int
simplefb_get_stride_pd(struct drm_device *dev,
		       const struct simplefb_platform_data *pd)
{}

static const struct drm_format_info *
simplefb_get_format_pd(struct drm_device *dev,
		       const struct simplefb_platform_data *pd)
{}

static int
simplefb_read_u32_of(struct drm_device *dev, struct device_node *of_node,
		     const char *name, u32 *value)
{}

static int
simplefb_read_string_of(struct drm_device *dev, struct device_node *of_node,
			const char *name, const char **value)
{}

static int
simplefb_get_width_of(struct drm_device *dev, struct device_node *of_node)
{}

static int
simplefb_get_height_of(struct drm_device *dev, struct device_node *of_node)
{}

static int
simplefb_get_stride_of(struct drm_device *dev, struct device_node *of_node)
{}

static const struct drm_format_info *
simplefb_get_format_of(struct drm_device *dev, struct device_node *of_node)
{}

static struct resource *
simplefb_get_memory_of(struct drm_device *dev, struct device_node *of_node)
{}

/*
 * Simple Framebuffer device
 */

struct simpledrm_device {};

static struct simpledrm_device *simpledrm_device_of_dev(struct drm_device *dev)
{}

/*
 * Hardware
 */

#if defined CONFIG_OF && defined CONFIG_COMMON_CLK
/*
 * Clock handling code.
 *
 * Here we handle the clocks property of our "simple-framebuffer" dt node.
 * This is necessary so that we can make sure that any clocks needed by
 * the display engine that the bootloader set up for us (and for which it
 * provided a simplefb dt node), stay up, for the life of the simplefb
 * driver.
 *
 * When the driver unloads, we cleanly disable, and then release the clocks.
 *
 * We only complain about errors here, no action is taken as the most likely
 * error can only happen due to a mismatch between the bootloader which set
 * up simplefb, and the clock definitions in the device tree. Chances are
 * that there are no adverse effects, and if there are, a clean teardown of
 * the fb probe will not help us much either. So just complain and carry on,
 * and hope that the user actually gets a working fb at the end of things.
 */

static void simpledrm_device_release_clocks(void *res)
{}

static int simpledrm_device_init_clocks(struct simpledrm_device *sdev)
{}
#else
static int simpledrm_device_init_clocks(struct simpledrm_device *sdev)
{
	return 0;
}
#endif

#if defined CONFIG_OF && defined CONFIG_REGULATOR

#define SUPPLY_SUFFIX

/*
 * Regulator handling code.
 *
 * Here we handle the num-supplies and vin*-supply properties of our
 * "simple-framebuffer" dt node. This is necessary so that we can make sure
 * that any regulators needed by the display hardware that the bootloader
 * set up for us (and for which it provided a simplefb dt node), stay up,
 * for the life of the simplefb driver.
 *
 * When the driver unloads, we cleanly disable, and then release the
 * regulators.
 *
 * We only complain about errors here, no action is taken as the most likely
 * error can only happen due to a mismatch between the bootloader which set
 * up simplefb, and the regulator definitions in the device tree. Chances are
 * that there are no adverse effects, and if there are, a clean teardown of
 * the fb probe will not help us much either. So just complain and carry on,
 * and hope that the user actually gets a working fb at the end of things.
 */

static void simpledrm_device_release_regulators(void *res)
{}

static int simpledrm_device_init_regulators(struct simpledrm_device *sdev)
{}
#else
static int simpledrm_device_init_regulators(struct simpledrm_device *sdev)
{
	return 0;
}
#endif

#if defined CONFIG_OF && defined CONFIG_PM_GENERIC_DOMAINS
/*
 * Generic power domain handling code.
 *
 * Here we handle the power-domains properties of our "simple-framebuffer"
 * dt node. This is only necessary if there is more than one power-domain.
 * A single power-domains is handled automatically by the driver core. Multiple
 * power-domains have to be handled by drivers since the driver core can't know
 * the correct power sequencing. Power sequencing is not an issue for simpledrm
 * since the bootloader has put the power domains already in the correct state.
 * simpledrm has only to ensure they remain active for its lifetime.
 *
 * When the driver unloads, we detach from the power-domains.
 *
 * We only complain about errors here, no action is taken as the most likely
 * error can only happen due to a mismatch between the bootloader which set
 * up the "simple-framebuffer" dt node, and the PM domain providers in the
 * device tree. Chances are that there are no adverse effects, and if there are,
 * a clean teardown of the fb probe will not help us much either. So just
 * complain and carry on, and hope that the user actually gets a working fb at
 * the end of things.
 */
static void simpledrm_device_detach_genpd(void *res)
{}

static int simpledrm_device_attach_genpd(struct simpledrm_device *sdev)
{}
#else
static int simpledrm_device_attach_genpd(struct simpledrm_device *sdev)
{
	return 0;
}
#endif

/*
 * Modesetting
 */

static const uint64_t simpledrm_primary_plane_format_modifiers[] =;

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

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

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

static int simpledrm_primary_plane_helper_get_scanout_buffer(struct drm_plane *plane,
							     struct drm_scanout_buffer *sb)
{}

static const struct drm_plane_helper_funcs simpledrm_primary_plane_helper_funcs =;

static const struct drm_plane_funcs simpledrm_primary_plane_funcs =;

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

/*
 * 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 simpledrm_crtc_helper_funcs =;

static const struct drm_crtc_funcs simpledrm_crtc_funcs =;

static const struct drm_encoder_funcs simpledrm_encoder_funcs =;

static int simpledrm_connector_helper_get_modes(struct drm_connector *connector)
{}

static const struct drm_connector_helper_funcs simpledrm_connector_helper_funcs =;

static const struct drm_connector_funcs simpledrm_connector_funcs =;

static const struct drm_mode_config_funcs simpledrm_mode_config_funcs =;

/*
 * Init / Cleanup
 */

static struct drm_display_mode simpledrm_mode(unsigned int width,
					      unsigned int height,
					      unsigned int width_mm,
					      unsigned int height_mm)
{}

static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
							struct platform_device *pdev)
{}

/*
 * DRM driver
 */

DEFINE_DRM_GEM_FOPS(simpledrm_fops);

static struct drm_driver simpledrm_driver =;

/*
 * Platform driver
 */

static int simpledrm_probe(struct platform_device *pdev)
{}

static void simpledrm_remove(struct platform_device *pdev)
{}

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

static struct platform_driver simpledrm_platform_driver =;

module_platform_driver();

MODULE_DESCRIPTION();
MODULE_LICENSE();