2019-06-04 15:11:33 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2012-11-16 04:28:22 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Avionic Design GmbH
|
2013-03-22 21:34:09 +07:00
|
|
|
* Copyright (C) 2012-2013 NVIDIA CORPORATION. All rights reserved.
|
2012-11-16 04:28:22 +07:00
|
|
|
*/
|
|
|
|
|
2013-03-22 21:34:05 +07:00
|
|
|
#ifndef HOST1X_DRM_H
|
|
|
|
#define HOST1X_DRM_H 1
|
2012-11-16 04:28:22 +07:00
|
|
|
|
2013-09-24 18:59:01 +07:00
|
|
|
#include <linux/host1x.h>
|
2016-12-14 18:16:11 +07:00
|
|
|
#include <linux/iova.h>
|
2020-04-15 19:24:27 +07:00
|
|
|
#include <linux/gpio/consumer.h>
|
2013-09-24 18:59:01 +07:00
|
|
|
|
2017-11-13 17:08:13 +07:00
|
|
|
#include <drm/drm_atomic.h>
|
2012-11-16 04:28:22 +07:00
|
|
|
#include <drm/drm_edid.h>
|
2016-11-29 01:51:09 +07:00
|
|
|
#include <drm/drm_encoder.h>
|
2012-11-16 04:28:22 +07:00
|
|
|
#include <drm/drm_fb_helper.h>
|
|
|
|
#include <drm/drm_fixed.h>
|
2019-01-18 04:03:34 +07:00
|
|
|
#include <drm/drm_probe_helper.h>
|
2019-08-04 16:41:30 +07:00
|
|
|
#include <uapi/drm/tegra_drm.h>
|
2012-11-16 04:28:22 +07:00
|
|
|
|
2014-06-03 19:48:12 +07:00
|
|
|
#include "gem.h"
|
2017-11-13 17:08:13 +07:00
|
|
|
#include "hub.h"
|
2017-08-15 20:41:10 +07:00
|
|
|
#include "trace.h"
|
2014-06-03 19:48:12 +07:00
|
|
|
|
2013-11-07 06:20:54 +07:00
|
|
|
struct reset_control;
|
|
|
|
|
2015-10-27 15:10:59 +07:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2013-03-22 21:34:08 +07:00
|
|
|
struct tegra_fbdev {
|
|
|
|
struct drm_fb_helper base;
|
2018-03-30 21:11:27 +07:00
|
|
|
struct drm_framebuffer *fb;
|
2013-03-22 21:34:08 +07:00
|
|
|
};
|
2013-10-31 19:28:50 +07:00
|
|
|
#endif
|
2013-03-22 21:34:08 +07:00
|
|
|
|
2013-09-24 18:22:17 +07:00
|
|
|
struct tegra_drm {
|
2012-11-16 04:28:22 +07:00
|
|
|
struct drm_device *drm;
|
|
|
|
|
2014-06-27 02:41:53 +07:00
|
|
|
struct iommu_domain *domain;
|
2019-10-28 19:37:18 +07:00
|
|
|
bool use_explicit_iommu;
|
2017-03-10 02:04:56 +07:00
|
|
|
struct mutex mm_lock;
|
2014-06-27 02:41:53 +07:00
|
|
|
struct drm_mm mm;
|
|
|
|
|
2016-12-14 18:16:11 +07:00
|
|
|
struct {
|
|
|
|
struct iova_domain domain;
|
|
|
|
unsigned long shift;
|
|
|
|
unsigned long limit;
|
|
|
|
} carveout;
|
|
|
|
|
2012-11-16 04:28:22 +07:00
|
|
|
struct mutex clients_lock;
|
|
|
|
struct list_head clients;
|
|
|
|
|
2015-10-27 15:10:59 +07:00
|
|
|
#ifdef CONFIG_DRM_FBDEV_EMULATION
|
2013-03-22 21:34:08 +07:00
|
|
|
struct tegra_fbdev *fbdev;
|
2013-10-31 19:28:50 +07:00
|
|
|
#endif
|
2014-07-11 13:29:14 +07:00
|
|
|
|
|
|
|
unsigned int pitch_align;
|
2014-11-24 23:41:23 +07:00
|
|
|
|
2017-11-13 17:08:13 +07:00
|
|
|
struct tegra_display_hub *hub;
|
2012-11-16 04:28:22 +07:00
|
|
|
};
|
|
|
|
|
2013-09-24 20:35:40 +07:00
|
|
|
struct tegra_drm_client;
|
2012-11-16 04:28:22 +07:00
|
|
|
|
2013-09-26 21:08:22 +07:00
|
|
|
struct tegra_drm_context {
|
2013-09-24 20:35:40 +07:00
|
|
|
struct tegra_drm_client *client;
|
2013-03-22 21:34:09 +07:00
|
|
|
struct host1x_channel *channel;
|
2017-03-10 02:04:55 +07:00
|
|
|
unsigned int id;
|
2013-03-22 21:34:09 +07:00
|
|
|
};
|
|
|
|
|
2013-09-24 20:35:40 +07:00
|
|
|
struct tegra_drm_client_ops {
|
|
|
|
int (*open_channel)(struct tegra_drm_client *client,
|
2013-09-26 21:08:22 +07:00
|
|
|
struct tegra_drm_context *context);
|
|
|
|
void (*close_channel)(struct tegra_drm_context *context);
|
2013-10-10 16:00:33 +07:00
|
|
|
int (*is_addr_reg)(struct device *dev, u32 class, u32 offset);
|
2017-06-15 06:18:37 +07:00
|
|
|
int (*is_valid_class)(u32 class);
|
2013-09-26 21:08:22 +07:00
|
|
|
int (*submit)(struct tegra_drm_context *context,
|
2013-03-22 21:34:09 +07:00
|
|
|
struct drm_tegra_submit *args, struct drm_device *drm,
|
|
|
|
struct drm_file *file);
|
|
|
|
};
|
|
|
|
|
2013-10-10 16:00:33 +07: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 20:35:40 +07:00
|
|
|
struct tegra_drm_client {
|
|
|
|
struct host1x_client base;
|
2013-10-14 19:43:22 +07:00
|
|
|
struct list_head list;
|
2019-02-01 20:28:31 +07:00
|
|
|
struct tegra_drm *drm;
|
2013-03-22 21:34:09 +07:00
|
|
|
|
2018-05-16 22:05:04 +07:00
|
|
|
unsigned int version;
|
2013-09-24 20:35:40 +07:00
|
|
|
const struct tegra_drm_client_ops *ops;
|
2012-11-16 04:28:22 +07:00
|
|
|
};
|
|
|
|
|
2013-09-24 20:35:40 +07:00
|
|
|
static inline struct tegra_drm_client *
|
2013-10-14 19:43:22 +07:00
|
|
|
host1x_to_drm_client(struct host1x_client *client)
|
2013-09-24 20:35:40 +07:00
|
|
|
{
|
|
|
|
return container_of(client, struct tegra_drm_client, base);
|
|
|
|
}
|
|
|
|
|
2014-04-16 14:54:21 +07: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);
|
2019-10-28 19:37:08 +07:00
|
|
|
int host1x_client_iommu_attach(struct host1x_client *client);
|
2019-02-08 20:35:13 +07:00
|
|
|
void host1x_client_iommu_detach(struct host1x_client *client);
|
2013-10-14 19:43:22 +07:00
|
|
|
|
2014-04-16 14:54:21 +07:00
|
|
|
int tegra_drm_init(struct tegra_drm *tegra, struct drm_device *drm);
|
|
|
|
int tegra_drm_exit(struct tegra_drm *tegra);
|
2012-11-16 04:28:22 +07:00
|
|
|
|
2016-12-14 18:16:11 +07:00
|
|
|
void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, dma_addr_t *iova);
|
|
|
|
void tegra_drm_free(struct tegra_drm *tegra, size_t size, void *virt,
|
|
|
|
dma_addr_t iova);
|
|
|
|
|
2017-09-11 19:29:52 +07:00
|
|
|
struct cec_notifier;
|
|
|
|
|
2012-11-16 04:28:22 +07:00
|
|
|
struct tegra_output {
|
|
|
|
struct device_node *of_node;
|
|
|
|
struct device *dev;
|
|
|
|
|
2013-08-30 20:22:36 +07:00
|
|
|
struct drm_panel *panel;
|
2012-11-16 04:28:22 +07:00
|
|
|
struct i2c_adapter *ddc;
|
|
|
|
const struct edid *edid;
|
2018-12-10 23:34:54 +07:00
|
|
|
struct cec_notifier *cec;
|
2012-11-16 04:28:22 +07:00
|
|
|
unsigned int hpd_irq;
|
2019-06-05 15:46:46 +07:00
|
|
|
struct gpio_desc *hpd_gpio;
|
2012-11-16 04:28:22 +07: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 output.c */
|
2014-04-16 14:54:21 +07:00
|
|
|
int tegra_output_probe(struct tegra_output *output);
|
2014-12-19 21:55:08 +07:00
|
|
|
void tegra_output_remove(struct tegra_output *output);
|
2014-04-16 14:54:21 +07:00
|
|
|
int tegra_output_init(struct drm_device *drm, struct tegra_output *output);
|
2014-12-19 21:55:08 +07:00
|
|
|
void tegra_output_exit(struct tegra_output *output);
|
2017-10-13 00:12:57 +07:00
|
|
|
void tegra_output_find_possible_crtcs(struct tegra_output *output,
|
|
|
|
struct drm_device *drm);
|
2019-12-02 21:29:03 +07:00
|
|
|
int tegra_output_suspend(struct tegra_output *output);
|
|
|
|
int tegra_output_resume(struct tegra_output *output);
|
2012-11-16 04:28:22 +07:00
|
|
|
|
2014-11-28 21:38:40 +07: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);
|
|
|
|
|
2013-11-15 22:06:05 +07:00
|
|
|
/* from dpaux.c */
|
2015-07-08 18:39:09 +07: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);
|
2013-11-15 22:06:05 +07:00
|
|
|
|
2012-11-16 04:28:22 +07:00
|
|
|
/* from fb.c */
|
2013-03-22 21:34:08 +07:00
|
|
|
struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
|
|
|
|
unsigned int index);
|
2013-10-07 14:47:58 +07:00
|
|
|
bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer);
|
2014-06-03 19:48:12 +07:00
|
|
|
int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
|
|
|
|
struct tegra_bo_tiling *tiling);
|
2014-11-26 19:03:57 +07:00
|
|
|
struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
|
|
|
|
struct drm_file *file,
|
2015-11-12 00:11:29 +07:00
|
|
|
const struct drm_mode_fb_cmd2 *cmd);
|
2014-06-27 22:19:25 +07:00
|
|
|
int tegra_drm_fb_prepare(struct drm_device *drm);
|
2014-11-06 20:12:08 +07:00
|
|
|
void tegra_drm_fb_free(struct drm_device *drm);
|
2014-04-16 14:54:21 +07:00
|
|
|
int tegra_drm_fb_init(struct drm_device *drm);
|
|
|
|
void tegra_drm_fb_exit(struct drm_device *drm);
|
2012-11-16 04:28:22 +07:00
|
|
|
|
2017-11-13 17:08:13 +07:00
|
|
|
extern struct platform_driver tegra_display_hub_driver;
|
2013-10-14 19:43:22 +07:00
|
|
|
extern struct platform_driver tegra_dc_driver;
|
|
|
|
extern struct platform_driver tegra_hdmi_driver;
|
2015-09-10 21:07:14 +07:00
|
|
|
extern struct platform_driver tegra_dsi_driver;
|
2013-11-15 22:06:05 +07:00
|
|
|
extern struct platform_driver tegra_dpaux_driver;
|
2015-09-10 21:07:14 +07:00
|
|
|
extern struct platform_driver tegra_sor_driver;
|
2013-10-14 19:43:22 +07:00
|
|
|
extern struct platform_driver tegra_gr2d_driver;
|
2013-02-28 14:08:01 +07:00
|
|
|
extern struct platform_driver tegra_gr3d_driver;
|
2016-12-14 18:16:13 +07:00
|
|
|
extern struct platform_driver tegra_vic_driver;
|
2012-11-16 04:28:22 +07:00
|
|
|
|
2013-03-22 21:34:05 +07:00
|
|
|
#endif /* HOST1X_DRM_H */
|