2012-11-15 21:28:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Avionic Design GmbH
|
2013-03-22 14:34:09 +00:00
|
|
|
* Copyright (C) 2012-2013 NVIDIA CORPORATION. All rights reserved.
|
2012-11-15 21:28:22 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
2013-03-22 14:34:05 +00:00
|
|
|
#ifndef HOST1X_DRM_H
|
|
|
|
#define HOST1X_DRM_H 1
|
2012-11-15 21:28:22 +00:00
|
|
|
|
2013-09-24 11:59:01 +00:00
|
|
|
#include <uapi/drm/tegra_drm.h>
|
|
|
|
#include <linux/host1x.h>
|
2015-04-27 13:12:39 +00:00
|
|
|
#include <linux/of_gpio.h>
|
2013-09-24 11:59:01 +00:00
|
|
|
|
2012-11-15 21:28:22 +00:00
|
|
|
#include <drm/drmP.h>
|
|
|
|
#include <drm/drm_crtc_helper.h>
|
|
|
|
#include <drm/drm_edid.h>
|
|
|
|
#include <drm/drm_fb_helper.h>
|
|
|
|
#include <drm/drm_fixed.h>
|
|
|
|
|
2014-06-03 12:48:12 +00:00
|
|
|
#include "gem.h"
|
|
|
|
|
2013-11-06 23:20:54 +00:00
|
|
|
struct reset_control;
|
|
|
|
|
2013-03-22 14:34:08 +00:00
|
|
|
struct tegra_fb {
|
|
|
|
struct drm_framebuffer base;
|
|
|
|
struct tegra_bo **planes;
|
|
|
|
unsigned int num_planes;
|
|
|
|
};
|
|
|
|
|
2015-10-27 08:10:59 +00:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2013-03-22 14:34:08 +00:00
|
|
|
struct tegra_fbdev {
|
|
|
|
struct drm_fb_helper base;
|
|
|
|
struct tegra_fb *fb;
|
|
|
|
};
|
2013-10-31 12:28:50 +00:00
|
|
|
#endif
|
2013-03-22 14:34:08 +00:00
|
|
|
|
2013-09-24 11:22:17 +00:00
|
|
|
struct tegra_drm {
|
2012-11-15 21:28:22 +00:00
|
|
|
struct drm_device *drm;
|
|
|
|
|
2014-06-26 19:41:53 +00:00
|
|
|
struct iommu_domain *domain;
|
|
|
|
struct drm_mm mm;
|
|
|
|
|
2012-11-15 21:28:22 +00:00
|
|
|
struct mutex clients_lock;
|
|
|
|
struct list_head clients;
|
|
|
|
|
2015-10-27 08:10:59 +00:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2013-03-22 14:34:08 +00:00
|
|
|
struct tegra_fbdev *fbdev;
|
2013-10-31 12:28:50 +00:00
|
|
|
#endif
|
2014-07-11 06:29:14 +00:00
|
|
|
|
|
|
|
unsigned int pitch_align;
|
2014-11-24 16:41:23 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct drm_atomic_state *state;
|
|
|
|
struct work_struct work;
|
|
|
|
struct mutex lock;
|
|
|
|
} commit;
|
2015-08-11 11:11:49 +00:00
|
|
|
|
|
|
|
struct drm_atomic_state *state;
|
2012-11-15 21:28:22 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 13:35:40 +00:00
|
|
|
struct tegra_drm_client;
|
2012-11-15 21:28:22 +00:00
|
|
|
|
2013-09-26 14:08:22 +00:00
|
|
|
struct tegra_drm_context {
|
2013-09-24 13:35:40 +00:00
|
|
|
struct tegra_drm_client *client;
|
2013-03-22 14:34:09 +00:00
|
|
|
struct host1x_channel *channel;
|
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
2013-09-24 13:35:40 +00:00
|
|
|
struct tegra_drm_client_ops {
|
|
|
|
int (*open_channel)(struct tegra_drm_client *client,
|
2013-09-26 14:08:22 +00:00
|
|
|
struct tegra_drm_context *context);
|
|
|
|
void (*close_channel)(struct tegra_drm_context *context);
|
2013-10-10 09:00:33 +00:00
|
|
|
int (*is_addr_reg)(struct device *dev, u32 class, u32 offset);
|
2013-09-26 14:08:22 +00:00
|
|
|
int (*submit)(struct tegra_drm_context *context,
|
2013-03-22 14:34:09 +00:00
|
|
|
struct drm_tegra_submit *args, struct drm_device *drm,
|
|
|
|
struct drm_file *file);
|
|
|
|
};
|
|
|
|
|
2013-10-10 09:00:33 +00:00
|
|
|
int tegra_drm_submit(struct tegra_drm_context *context,
|
|
|
|
struct drm_tegra_submit *args, struct drm_device *drm,
|
|
|
|
struct drm_file *file);
|
|
|
|
|
2013-09-24 13:35:40 +00:00
|
|
|
struct tegra_drm_client {
|
|
|
|
struct host1x_client base;
|
2013-10-14 12:43:22 +00:00
|
|
|
struct list_head list;
|
2013-03-22 14:34:09 +00:00
|
|
|
|
2013-09-24 13:35:40 +00:00
|
|
|
const struct tegra_drm_client_ops *ops;
|
2012-11-15 21:28:22 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 13:35:40 +00:00
|
|
|
static inline struct tegra_drm_client *
|
2013-10-14 12:43:22 +00:00
|
|
|
host1x_to_drm_client(struct host1x_client *client)
|
2013-09-24 13:35:40 +00:00
|
|
|
{
|
|
|
|
return container_of(client, struct tegra_drm_client, base);
|
|
|
|
}
|
|
|
|
|
2014-04-16 07:54:21 +00:00
|
|
|
int tegra_drm_register_client(struct tegra_drm *tegra,
|
|
|
|
struct tegra_drm_client *client);
|
|
|
|
int tegra_drm_unregister_client(struct tegra_drm *tegra,
|
|
|
|
struct tegra_drm_client *client);
|
2013-10-14 12:43:22 +00:00
|
|
|
|
2014-04-16 07:54:21 +00:00
|
|
|
int tegra_drm_init(struct tegra_drm *tegra, struct drm_device *drm);
|
|
|
|
int tegra_drm_exit(struct tegra_drm *tegra);
|
2012-11-15 21:28:22 +00:00
|
|
|
|
2013-12-12 10:03:59 +00:00
|
|
|
struct tegra_dc_soc_info;
|
2012-11-15 21:28:22 +00:00
|
|
|
struct tegra_output;
|
|
|
|
|
2015-07-28 19:27:05 +00:00
|
|
|
struct tegra_dc_stats {
|
|
|
|
unsigned long frames;
|
|
|
|
unsigned long vblank;
|
|
|
|
unsigned long underflow;
|
|
|
|
unsigned long overflow;
|
|
|
|
};
|
|
|
|
|
2012-11-15 21:28:22 +00:00
|
|
|
struct tegra_dc {
|
2013-10-14 12:43:22 +00:00
|
|
|
struct host1x_client client;
|
2015-01-28 13:43:05 +00:00
|
|
|
struct host1x_syncpt *syncpt;
|
2012-11-15 21:28:22 +00:00
|
|
|
struct device *dev;
|
2013-09-26 14:09:19 +00:00
|
|
|
spinlock_t lock;
|
2012-11-15 21:28:22 +00:00
|
|
|
|
|
|
|
struct drm_crtc base;
|
2016-02-11 18:03:22 +00:00
|
|
|
unsigned int powergate;
|
2012-11-15 21:28:22 +00:00
|
|
|
int pipe;
|
|
|
|
|
|
|
|
struct clk *clk;
|
2013-11-06 23:20:54 +00:00
|
|
|
struct reset_control *rst;
|
2012-11-15 21:28:22 +00:00
|
|
|
void __iomem *regs;
|
|
|
|
int irq;
|
|
|
|
|
|
|
|
struct tegra_output *rgb;
|
|
|
|
|
2015-07-28 19:27:05 +00:00
|
|
|
struct tegra_dc_stats stats;
|
2012-11-15 21:28:22 +00:00
|
|
|
struct list_head list;
|
|
|
|
|
|
|
|
struct drm_info_list *debugfs_files;
|
|
|
|
struct drm_minor *minor;
|
|
|
|
struct dentry *debugfs;
|
2012-11-28 11:00:18 +00:00
|
|
|
|
|
|
|
/* page-flip handling */
|
|
|
|
struct drm_pending_vblank_event *event;
|
2013-12-12 10:03:59 +00:00
|
|
|
|
|
|
|
const struct tegra_dc_soc_info *soc;
|
2014-06-26 19:41:53 +00:00
|
|
|
|
|
|
|
struct iommu_domain *domain;
|
2012-11-15 21:28:22 +00:00
|
|
|
};
|
|
|
|
|
2013-09-24 13:35:40 +00:00
|
|
|
static inline struct tegra_dc *
|
2013-10-14 12:43:22 +00:00
|
|
|
host1x_client_to_dc(struct host1x_client *client)
|
2012-11-15 21:28:22 +00:00
|
|
|
{
|
|
|
|
return container_of(client, struct tegra_dc, client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct tegra_dc *to_tegra_dc(struct drm_crtc *crtc)
|
|
|
|
{
|
2013-11-08 11:30:37 +00:00
|
|
|
return crtc ? container_of(crtc, struct tegra_dc, base) : NULL;
|
2012-11-15 21:28:22 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 11:48:48 +00:00
|
|
|
static inline void tegra_dc_writel(struct tegra_dc *dc, u32 value,
|
|
|
|
unsigned long offset)
|
2012-11-15 21:28:22 +00:00
|
|
|
{
|
2014-10-21 11:48:48 +00:00
|
|
|
writel(value, dc->regs + (offset << 2));
|
2012-11-15 21:28:22 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 11:48:48 +00:00
|
|
|
static inline u32 tegra_dc_readl(struct tegra_dc *dc, unsigned long offset)
|
2012-11-15 21:28:22 +00:00
|
|
|
{
|
2014-10-21 11:48:48 +00:00
|
|
|
return readl(dc->regs + (offset << 2));
|
2012-11-15 21:28:22 +00:00
|
|
|
}
|
|
|
|
|
2012-11-04 20:47:13 +00:00
|
|
|
struct tegra_dc_window {
|
|
|
|
struct {
|
|
|
|
unsigned int x;
|
|
|
|
unsigned int y;
|
|
|
|
unsigned int w;
|
|
|
|
unsigned int h;
|
|
|
|
} src;
|
|
|
|
struct {
|
|
|
|
unsigned int x;
|
|
|
|
unsigned int y;
|
|
|
|
unsigned int w;
|
|
|
|
unsigned int h;
|
|
|
|
} dst;
|
|
|
|
unsigned int bits_per_pixel;
|
|
|
|
unsigned int stride[2];
|
|
|
|
unsigned long base[3];
|
2013-10-07 07:47:58 +00:00
|
|
|
bool bottom_up;
|
2014-06-03 12:48:12 +00:00
|
|
|
|
|
|
|
struct tegra_bo_tiling tiling;
|
2014-11-28 12:14:55 +00:00
|
|
|
u32 format;
|
|
|
|
u32 swap;
|
2012-11-04 20:47:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* from dc.c */
|
2015-01-28 13:43:05 +00:00
|
|
|
u32 tegra_dc_get_vblank_counter(struct tegra_dc *dc);
|
2014-04-16 07:54:21 +00:00
|
|
|
void tegra_dc_enable_vblank(struct tegra_dc *dc);
|
|
|
|
void tegra_dc_disable_vblank(struct tegra_dc *dc);
|
2014-11-21 16:33:33 +00:00
|
|
|
void tegra_dc_commit(struct tegra_dc *dc);
|
2014-12-08 15:14:45 +00:00
|
|
|
int tegra_dc_state_setup_clock(struct tegra_dc *dc,
|
|
|
|
struct drm_crtc_state *crtc_state,
|
|
|
|
struct clk *clk, unsigned long pclk,
|
|
|
|
unsigned int div);
|
2012-11-04 20:47:13 +00:00
|
|
|
|
2012-11-15 21:28:22 +00:00
|
|
|
struct tegra_output {
|
|
|
|
struct device_node *of_node;
|
|
|
|
struct device *dev;
|
|
|
|
|
2013-08-30 13:22:36 +00:00
|
|
|
struct drm_panel *panel;
|
2012-11-15 21:28:22 +00:00
|
|
|
struct i2c_adapter *ddc;
|
|
|
|
const struct edid *edid;
|
|
|
|
unsigned int hpd_irq;
|
|
|
|
int hpd_gpio;
|
2015-04-27 13:12:39 +00:00
|
|
|
enum of_gpio_flags hpd_gpio_flags;
|
2012-11-15 21:28:22 +00:00
|
|
|
|
|
|
|
struct drm_encoder encoder;
|
|
|
|
struct drm_connector connector;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct tegra_output *encoder_to_output(struct drm_encoder *e)
|
|
|
|
{
|
|
|
|
return container_of(e, struct tegra_output, encoder);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct tegra_output *connector_to_output(struct drm_connector *c)
|
|
|
|
{
|
|
|
|
return container_of(c, struct tegra_output, connector);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* from rgb.c */
|
2014-04-16 07:54:21 +00:00
|
|
|
int tegra_dc_rgb_probe(struct tegra_dc *dc);
|
|
|
|
int tegra_dc_rgb_remove(struct tegra_dc *dc);
|
|
|
|
int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc);
|
|
|
|
int tegra_dc_rgb_exit(struct tegra_dc *dc);
|
2012-11-15 21:28:22 +00:00
|
|
|
|
|
|
|
/* from output.c */
|
2014-04-16 07:54:21 +00:00
|
|
|
int tegra_output_probe(struct tegra_output *output);
|
2014-12-19 14:55:08 +00:00
|
|
|
void tegra_output_remove(struct tegra_output *output);
|
2014-04-16 07:54:21 +00:00
|
|
|
int tegra_output_init(struct drm_device *drm, struct tegra_output *output);
|
2014-12-19 14:55:08 +00:00
|
|
|
void tegra_output_exit(struct tegra_output *output);
|
2012-11-15 21:28:22 +00:00
|
|
|
|
2014-11-28 14:38:40 +00:00
|
|
|
int tegra_output_connector_get_modes(struct drm_connector *connector);
|
|
|
|
enum drm_connector_status
|
|
|
|
tegra_output_connector_detect(struct drm_connector *connector, bool force);
|
|
|
|
void tegra_output_connector_destroy(struct drm_connector *connector);
|
|
|
|
|
|
|
|
void tegra_output_encoder_destroy(struct drm_encoder *encoder);
|
|
|
|
|
2013-11-15 15:06:05 +00:00
|
|
|
/* from dpaux.c */
|
|
|
|
struct drm_dp_link;
|
|
|
|
|
2015-07-08 11:39:09 +00:00
|
|
|
struct drm_dp_aux *drm_dp_aux_find_by_of_node(struct device_node *np);
|
|
|
|
enum drm_connector_status drm_dp_aux_detect(struct drm_dp_aux *aux);
|
|
|
|
int drm_dp_aux_attach(struct drm_dp_aux *aux, struct tegra_output *output);
|
|
|
|
int drm_dp_aux_detach(struct drm_dp_aux *aux);
|
|
|
|
int drm_dp_aux_enable(struct drm_dp_aux *aux);
|
|
|
|
int drm_dp_aux_disable(struct drm_dp_aux *aux);
|
|
|
|
int drm_dp_aux_prepare(struct drm_dp_aux *aux, u8 encoding);
|
|
|
|
int drm_dp_aux_train(struct drm_dp_aux *aux, struct drm_dp_link *link,
|
|
|
|
u8 pattern);
|
2013-11-15 15:06:05 +00:00
|
|
|
|
2012-11-15 21:28:22 +00:00
|
|
|
/* from fb.c */
|
2013-03-22 14:34:08 +00:00
|
|
|
struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
|
|
|
|
unsigned int index);
|
2013-10-07 07:47:58 +00:00
|
|
|
bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer);
|
2014-06-03 12:48:12 +00:00
|
|
|
int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
|
|
|
|
struct tegra_bo_tiling *tiling);
|
2014-11-26 12:03:57 +00:00
|
|
|
struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
|
|
|
|
struct drm_file *file,
|
2015-11-11 17:11:29 +00:00
|
|
|
const struct drm_mode_fb_cmd2 *cmd);
|
2014-06-27 15:19:25 +00:00
|
|
|
int tegra_drm_fb_prepare(struct drm_device *drm);
|
2014-11-06 13:12:08 +00:00
|
|
|
void tegra_drm_fb_free(struct drm_device *drm);
|
2014-04-16 07:54:21 +00:00
|
|
|
int tegra_drm_fb_init(struct drm_device *drm);
|
|
|
|
void tegra_drm_fb_exit(struct drm_device *drm);
|
2015-08-11 11:11:49 +00:00
|
|
|
void tegra_drm_fb_suspend(struct drm_device *drm);
|
|
|
|
void tegra_drm_fb_resume(struct drm_device *drm);
|
2015-10-27 08:10:59 +00:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2014-04-16 07:54:21 +00:00
|
|
|
void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev);
|
2014-11-26 12:03:57 +00:00
|
|
|
void tegra_fb_output_poll_changed(struct drm_device *drm);
|
2013-10-31 12:28:50 +00:00
|
|
|
#endif
|
2012-11-15 21:28:22 +00:00
|
|
|
|
2013-10-14 12:43:22 +00:00
|
|
|
extern struct platform_driver tegra_dc_driver;
|
|
|
|
extern struct platform_driver tegra_hdmi_driver;
|
2015-09-10 14:07:14 +00:00
|
|
|
extern struct platform_driver tegra_dsi_driver;
|
2013-11-15 15:06:05 +00:00
|
|
|
extern struct platform_driver tegra_dpaux_driver;
|
2015-09-10 14:07:14 +00:00
|
|
|
extern struct platform_driver tegra_sor_driver;
|
2013-10-14 12:43:22 +00:00
|
|
|
extern struct platform_driver tegra_gr2d_driver;
|
2013-02-28 07:08:01 +00:00
|
|
|
extern struct platform_driver tegra_gr3d_driver;
|
2012-11-15 21:28:22 +00:00
|
|
|
|
2013-03-22 14:34:05 +00:00
|
|
|
#endif /* HOST1X_DRM_H */
|