Linux Audio

Check our new training course

Loading...
v5.9
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright (C) 2012 Texas Instruments
  4 * Author: Rob Clark <robdclark@gmail.com>
 
 
 
 
 
 
 
 
 
 
 
 
  5 */
  6
  7#ifndef __TILCDC_DRV_H__
  8#define __TILCDC_DRV_H__
  9
 
 10#include <linux/cpufreq.h>
 11#include <linux/irqreturn.h>
 12
 13#include <drm/drm_print.h>
 14
 15struct clk;
 16struct workqueue_struct;
 17
 18struct drm_connector;
 19struct drm_connector_helper_funcs;
 20struct drm_crtc;
 21struct drm_device;
 22struct drm_display_mode;
 23struct drm_encoder;
 24struct drm_framebuffer;
 25struct drm_minor;
 26struct drm_pending_vblank_event;
 27struct drm_plane;
 28
 29/* Defaulting to pixel clock defined on AM335x */
 30#define TILCDC_DEFAULT_MAX_PIXELCLOCK  126000
 31/* Defaulting to max width as defined on AM335x */
 32#define TILCDC_DEFAULT_MAX_WIDTH  2048
 33/*
 34 * This may need some tweaking, but want to allow at least 1280x1024@60
 35 * with optimized DDR & EMIF settings tweaked 1920x1080@24 appears to
 36 * be supportable
 37 */
 38#define TILCDC_DEFAULT_MAX_BANDWIDTH  (1280*1024*60)
 39
 40
 41struct tilcdc_drm_private {
 42	void __iomem *mmio;
 43
 44	struct clk *clk;         /* functional clock */
 45	int rev;                 /* IP revision */
 46
 47	/* don't attempt resolutions w/ higher W * H * Hz: */
 48	uint32_t max_bandwidth;
 49	/*
 50	 * Pixel Clock will be restricted to some value as
 51	 * defined in the device datasheet measured in KHz
 52	 */
 53	uint32_t max_pixelclock;
 54	/*
 55	 * Max allowable width is limited on a per device basis
 56	 * measured in pixels
 57	 */
 58	uint32_t max_width;
 59
 60	/* Supported pixel formats */
 61	const uint32_t *pixelformats;
 62	uint32_t num_pixelformats;
 63
 64#ifdef CONFIG_CPU_FREQ
 65	struct notifier_block freq_transition;
 
 66#endif
 67
 68	struct workqueue_struct *wq;
 69
 
 
 70	struct drm_crtc *crtc;
 71
 72	unsigned int num_encoders;
 73	struct drm_encoder *encoders[8];
 74
 75	unsigned int num_connectors;
 76	struct drm_connector *connectors[8];
 
 77
 78	struct drm_encoder *external_encoder;
 79	struct drm_connector *external_connector;
 80
 81	bool is_registered;
 82	bool is_componentized;
 83};
 84
 85/* Sub-module for display.  Since we don't know at compile time what panels
 86 * or display adapter(s) might be present (for ex, off chip dvi/tfp410,
 87 * hdmi encoder, various lcd panels), the connector/encoder(s) are split into
 88 * separate drivers.  If they are probed and found to be present, they
 89 * register themselves with tilcdc_register_module().
 90 */
 91struct tilcdc_module;
 92
 93struct tilcdc_module_ops {
 94	/* create appropriate encoders/connectors: */
 95	int (*modeset_init)(struct tilcdc_module *mod, struct drm_device *dev);
 96#ifdef CONFIG_DEBUG_FS
 97	/* create debugfs nodes (can be NULL): */
 98	int (*debugfs_init)(struct tilcdc_module *mod, struct drm_minor *minor);
 
 
 99#endif
100};
101
102struct tilcdc_module {
103	const char *name;
104	struct list_head list;
105	const struct tilcdc_module_ops *funcs;
 
106};
107
108void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
109		const struct tilcdc_module_ops *funcs);
110void tilcdc_module_cleanup(struct tilcdc_module *mod);
111
112/* Panel config that needs to be set in the crtc, but is not coming from
113 * the mode timings.  The display module is expected to call
114 * tilcdc_crtc_set_panel_info() to set this during modeset.
115 */
116struct tilcdc_panel_info {
117
118	/* AC Bias Pin Frequency */
119	uint32_t ac_bias;
120
121	/* AC Bias Pin Transitions per Interrupt */
122	uint32_t ac_bias_intrpt;
123
124	/* DMA burst size */
125	uint32_t dma_burst_sz;
126
127	/* Bits per pixel */
128	uint32_t bpp;
129
130	/* FIFO DMA Request Delay */
131	uint32_t fdd;
132
133	/* TFT Alternative Signal Mapping (Only for active) */
134	bool tft_alt_mode;
135
136	/* Invert pixel clock */
137	bool invert_pxl_clk;
138
139	/* Horizontal and Vertical Sync Edge: 0=rising 1=falling */
140	uint32_t sync_edge;
141
142	/* Horizontal and Vertical Sync: Control: 0=ignore */
143	uint32_t sync_ctrl;
144
145	/* Raster Data Order Select: 1=Most-to-least 0=Least-to-most */
146	uint32_t raster_order;
147
148	/* DMA FIFO threshold */
149	uint32_t fifo_th;
150};
151
152#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
153
154int tilcdc_crtc_create(struct drm_device *dev);
155irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
156void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
157void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
158		const struct tilcdc_panel_info *info);
159void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
160					bool simulate_vesa_sync);
 
161int tilcdc_crtc_max_width(struct drm_crtc *crtc);
162void tilcdc_crtc_shutdown(struct drm_crtc *crtc);
163int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
164		struct drm_framebuffer *fb,
165		struct drm_pending_vblank_event *event);
166
167int tilcdc_plane_init(struct drm_device *dev, struct drm_plane *plane);
168
169#endif /* __TILCDC_DRV_H__ */
v4.6
 
  1/*
  2 * Copyright (C) 2012 Texas Instruments
  3 * Author: Rob Clark <robdclark@gmail.com>
  4 *
  5 * This program is free software; you can redistribute it and/or modify it
  6 * under the terms of the GNU General Public License version 2 as published by
  7 * the Free Software Foundation.
  8 *
  9 * This program is distributed in the hope that it will be useful, but WITHOUT
 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 12 * more details.
 13 *
 14 * You should have received a copy of the GNU General Public License along with
 15 * this program.  If not, see <http://www.gnu.org/licenses/>.
 16 */
 17
 18#ifndef __TILCDC_DRV_H__
 19#define __TILCDC_DRV_H__
 20
 21#include <linux/clk.h>
 22#include <linux/cpufreq.h>
 23#include <linux/module.h>
 24#include <linux/platform_device.h>
 25#include <linux/pm.h>
 26#include <linux/pm_runtime.h>
 27#include <linux/slab.h>
 28#include <linux/of.h>
 29#include <linux/of_device.h>
 30#include <linux/list.h>
 31
 32#include <drm/drmP.h>
 33#include <drm/drm_crtc_helper.h>
 34#include <drm/drm_gem_cma_helper.h>
 35#include <drm/drm_fb_cma_helper.h>
 
 
 
 
 36
 37/* Defaulting to pixel clock defined on AM335x */
 38#define TILCDC_DEFAULT_MAX_PIXELCLOCK  126000
 39/* Defaulting to max width as defined on AM335x */
 40#define TILCDC_DEFAULT_MAX_WIDTH  2048
 41/*
 42 * This may need some tweaking, but want to allow at least 1280x1024@60
 43 * with optimized DDR & EMIF settings tweaked 1920x1080@24 appears to
 44 * be supportable
 45 */
 46#define TILCDC_DEFAULT_MAX_BANDWIDTH  (1280*1024*60)
 47
 48
 49struct tilcdc_drm_private {
 50	void __iomem *mmio;
 51
 52	struct clk *clk;         /* functional clock */
 53	int rev;                 /* IP revision */
 54
 55	/* don't attempt resolutions w/ higher W * H * Hz: */
 56	uint32_t max_bandwidth;
 57	/*
 58	 * Pixel Clock will be restricted to some value as
 59	 * defined in the device datasheet measured in KHz
 60	 */
 61	uint32_t max_pixelclock;
 62	/*
 63	 * Max allowable width is limited on a per device basis
 64	 * measured in pixels
 65	 */
 66	uint32_t max_width;
 67
 68	/* register contents saved across suspend/resume: */
 69	u32 *saved_register;
 70	bool ctx_valid;
 71
 72#ifdef CONFIG_CPU_FREQ
 73	struct notifier_block freq_transition;
 74	unsigned int lcd_fck_rate;
 75#endif
 76
 77	struct workqueue_struct *wq;
 78
 79	struct drm_fbdev_cma *fbdev;
 80
 81	struct drm_crtc *crtc;
 82
 83	unsigned int num_encoders;
 84	struct drm_encoder *encoders[8];
 85
 86	unsigned int num_connectors;
 87	struct drm_connector *connectors[8];
 88	const struct drm_connector_helper_funcs *connector_funcs[8];
 89
 
 
 
 
 90	bool is_componentized;
 91};
 92
 93/* Sub-module for display.  Since we don't know at compile time what panels
 94 * or display adapter(s) might be present (for ex, off chip dvi/tfp410,
 95 * hdmi encoder, various lcd panels), the connector/encoder(s) are split into
 96 * separate drivers.  If they are probed and found to be present, they
 97 * register themselves with tilcdc_register_module().
 98 */
 99struct tilcdc_module;
100
101struct tilcdc_module_ops {
102	/* create appropriate encoders/connectors: */
103	int (*modeset_init)(struct tilcdc_module *mod, struct drm_device *dev);
104#ifdef CONFIG_DEBUG_FS
105	/* create debugfs nodes (can be NULL): */
106	int (*debugfs_init)(struct tilcdc_module *mod, struct drm_minor *minor);
107	/* cleanup debugfs nodes (can be NULL): */
108	void (*debugfs_cleanup)(struct tilcdc_module *mod, struct drm_minor *minor);
109#endif
110};
111
112struct tilcdc_module {
113	const char *name;
114	struct list_head list;
115	const struct tilcdc_module_ops *funcs;
116	unsigned int preferred_bpp;
117};
118
119void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
120		const struct tilcdc_module_ops *funcs);
121void tilcdc_module_cleanup(struct tilcdc_module *mod);
122
123/* Panel config that needs to be set in the crtc, but is not coming from
124 * the mode timings.  The display module is expected to call
125 * tilcdc_crtc_set_panel_info() to set this during modeset.
126 */
127struct tilcdc_panel_info {
128
129	/* AC Bias Pin Frequency */
130	uint32_t ac_bias;
131
132	/* AC Bias Pin Transitions per Interrupt */
133	uint32_t ac_bias_intrpt;
134
135	/* DMA burst size */
136	uint32_t dma_burst_sz;
137
138	/* Bits per pixel */
139	uint32_t bpp;
140
141	/* FIFO DMA Request Delay */
142	uint32_t fdd;
143
144	/* TFT Alternative Signal Mapping (Only for active) */
145	bool tft_alt_mode;
146
147	/* Invert pixel clock */
148	bool invert_pxl_clk;
149
150	/* Horizontal and Vertical Sync Edge: 0=rising 1=falling */
151	uint32_t sync_edge;
152
153	/* Horizontal and Vertical Sync: Control: 0=ignore */
154	uint32_t sync_ctrl;
155
156	/* Raster Data Order Select: 1=Most-to-least 0=Least-to-most */
157	uint32_t raster_order;
158
159	/* DMA FIFO threshold */
160	uint32_t fifo_th;
161};
162
163#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
164
165struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev);
166irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
167void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
168void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
169		const struct tilcdc_panel_info *info);
170void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
171					bool simulate_vesa_sync);
172int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode);
173int tilcdc_crtc_max_width(struct drm_crtc *crtc);
174void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode);
 
 
 
 
 
175
176#endif /* __TILCDC_DRV_H__ */