1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2dee8268fSThierry Reding /* 3dee8268fSThierry Reding * Copyright (C) 2012 Avionic Design GmbH 4dee8268fSThierry Reding * Copyright (C) 2012-2013 NVIDIA CORPORATION. All rights reserved. 5dee8268fSThierry Reding */ 6dee8268fSThierry Reding 7dee8268fSThierry Reding #ifndef HOST1X_DRM_H 8dee8268fSThierry Reding #define HOST1X_DRM_H 1 9dee8268fSThierry Reding 10dee8268fSThierry Reding #include <linux/host1x.h> 11ad926015SMikko Perttunen #include <linux/iova.h> 12ac2caae6SLinus Walleij #include <linux/gpio/consumer.h> 13dee8268fSThierry Reding 14c4755fb9SThierry Reding #include <drm/drm_atomic.h> 15f00b9dd5SDmitry Osipenko #include <drm/drm_bridge.h> 16dee8268fSThierry Reding #include <drm/drm_edid.h> 179338203cSLaurent Pinchart #include <drm/drm_encoder.h> 18dee8268fSThierry Reding #include <drm/drm_fb_helper.h> 19dee8268fSThierry Reding #include <drm/drm_fixed.h> 20fcd70cd3SDaniel Vetter #include <drm/drm_probe_helper.h> 21eb1df694SSam Ravnborg #include <uapi/drm/tegra_drm.h> 22dee8268fSThierry Reding 23c134f019SThierry Reding #include "gem.h" 24c4755fb9SThierry Reding #include "hub.h" 2567e04d1aSThierry Reding #include "trace.h" 26c134f019SThierry Reding 27ca48080aSStephen Warren struct reset_control; 28ca48080aSStephen Warren 29b110ef37SArchit Taneja #ifdef CONFIG_DRM_FBDEV_EMULATION 30dee8268fSThierry Reding struct tegra_fbdev { 31dee8268fSThierry Reding struct drm_fb_helper base; 32dbc33c7dSDaniel Stone struct drm_framebuffer *fb; 33dee8268fSThierry Reding }; 3460c2f709SThierry Reding #endif 35dee8268fSThierry Reding 36dee8268fSThierry Reding struct tegra_drm { 37dee8268fSThierry Reding struct drm_device *drm; 38dee8268fSThierry Reding 39df06b759SThierry Reding struct iommu_domain *domain; 40fa6661b7SThierry Reding bool use_explicit_iommu; 41347ad49dSThierry Reding struct mutex mm_lock; 42df06b759SThierry Reding struct drm_mm mm; 43df06b759SThierry Reding 44ad926015SMikko Perttunen struct { 45ad926015SMikko Perttunen struct iova_domain domain; 46ad926015SMikko Perttunen unsigned long shift; 47ad926015SMikko Perttunen unsigned long limit; 48ad926015SMikko Perttunen } carveout; 49ad926015SMikko Perttunen 50dee8268fSThierry Reding struct mutex clients_lock; 51dee8268fSThierry Reding struct list_head clients; 52dee8268fSThierry Reding 53b110ef37SArchit Taneja #ifdef CONFIG_DRM_FBDEV_EMULATION 54dee8268fSThierry Reding struct tegra_fbdev *fbdev; 5560c2f709SThierry Reding #endif 56d1f3e1e0SThierry Reding 57*042c0bd7SThierry Reding unsigned int hmask, vmask; 58d1f3e1e0SThierry Reding unsigned int pitch_align; 591503ca47SThierry Reding 60c4755fb9SThierry Reding struct tegra_display_hub *hub; 61dee8268fSThierry Reding }; 62dee8268fSThierry Reding 63dee8268fSThierry Reding struct tegra_drm_client; 64dee8268fSThierry Reding 65dee8268fSThierry Reding struct tegra_drm_context { 66dee8268fSThierry Reding struct tegra_drm_client *client; 67dee8268fSThierry Reding struct host1x_channel *channel; 68bdd2f9cdSThierry Reding unsigned int id; 69dee8268fSThierry Reding }; 70dee8268fSThierry Reding 71dee8268fSThierry Reding struct tegra_drm_client_ops { 72dee8268fSThierry Reding int (*open_channel)(struct tegra_drm_client *client, 73dee8268fSThierry Reding struct tegra_drm_context *context); 74dee8268fSThierry Reding void (*close_channel)(struct tegra_drm_context *context); 75c40f0f1aSThierry Reding int (*is_addr_reg)(struct device *dev, u32 class, u32 offset); 760f563a4bSDmitry Osipenko int (*is_valid_class)(u32 class); 77dee8268fSThierry Reding int (*submit)(struct tegra_drm_context *context, 78dee8268fSThierry Reding struct drm_tegra_submit *args, struct drm_device *drm, 79dee8268fSThierry Reding struct drm_file *file); 80dee8268fSThierry Reding }; 81dee8268fSThierry Reding 82c40f0f1aSThierry Reding int tegra_drm_submit(struct tegra_drm_context *context, 83c40f0f1aSThierry Reding struct drm_tegra_submit *args, struct drm_device *drm, 84c40f0f1aSThierry Reding struct drm_file *file); 85c40f0f1aSThierry Reding 86dee8268fSThierry Reding struct tegra_drm_client { 87dee8268fSThierry Reding struct host1x_client base; 88dee8268fSThierry Reding struct list_head list; 898e5d19c6SThierry Reding struct tegra_drm *drm; 90dee8268fSThierry Reding 91f3b3cfccSThierry Reding unsigned int version; 92dee8268fSThierry Reding const struct tegra_drm_client_ops *ops; 93dee8268fSThierry Reding }; 94dee8268fSThierry Reding 95dee8268fSThierry Reding static inline struct tegra_drm_client * 96dee8268fSThierry Reding host1x_to_drm_client(struct host1x_client *client) 97dee8268fSThierry Reding { 98dee8268fSThierry Reding return container_of(client, struct tegra_drm_client, base); 99dee8268fSThierry Reding } 100dee8268fSThierry Reding 101688c59afSThierry Reding int tegra_drm_register_client(struct tegra_drm *tegra, 102dee8268fSThierry Reding struct tegra_drm_client *client); 103688c59afSThierry Reding int tegra_drm_unregister_client(struct tegra_drm *tegra, 104dee8268fSThierry Reding struct tegra_drm_client *client); 1057edd7961SThierry Reding int host1x_client_iommu_attach(struct host1x_client *client); 106aacdf198SThierry Reding void host1x_client_iommu_detach(struct host1x_client *client); 107dee8268fSThierry Reding 108688c59afSThierry Reding int tegra_drm_init(struct tegra_drm *tegra, struct drm_device *drm); 109688c59afSThierry Reding int tegra_drm_exit(struct tegra_drm *tegra); 110dee8268fSThierry Reding 111ad926015SMikko Perttunen void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, dma_addr_t *iova); 112ad926015SMikko Perttunen void tegra_drm_free(struct tegra_drm *tegra, size_t size, void *virt, 113ad926015SMikko Perttunen dma_addr_t iova); 114ad926015SMikko Perttunen 115fb83be88SHans Verkuil struct cec_notifier; 116fb83be88SHans Verkuil 117dee8268fSThierry Reding struct tegra_output { 118dee8268fSThierry Reding struct device_node *of_node; 119dee8268fSThierry Reding struct device *dev; 120dee8268fSThierry Reding 121f00b9dd5SDmitry Osipenko struct drm_bridge *bridge; 1229be7d864SThierry Reding struct drm_panel *panel; 123dee8268fSThierry Reding struct i2c_adapter *ddc; 124dee8268fSThierry Reding const struct edid *edid; 125f25d0a68SThierry Reding struct cec_notifier *cec; 126dee8268fSThierry Reding unsigned int hpd_irq; 127bbad6407SThierry Reding struct gpio_desc *hpd_gpio; 128dee8268fSThierry Reding 129dee8268fSThierry Reding struct drm_encoder encoder; 130dee8268fSThierry Reding struct drm_connector connector; 131dee8268fSThierry Reding }; 132dee8268fSThierry Reding 133dee8268fSThierry Reding static inline struct tegra_output *encoder_to_output(struct drm_encoder *e) 134dee8268fSThierry Reding { 135dee8268fSThierry Reding return container_of(e, struct tegra_output, encoder); 136dee8268fSThierry Reding } 137dee8268fSThierry Reding 138dee8268fSThierry Reding static inline struct tegra_output *connector_to_output(struct drm_connector *c) 139dee8268fSThierry Reding { 140dee8268fSThierry Reding return container_of(c, struct tegra_output, connector); 141dee8268fSThierry Reding } 142dee8268fSThierry Reding 143dee8268fSThierry Reding /* from output.c */ 144688c59afSThierry Reding int tegra_output_probe(struct tegra_output *output); 145328ec69eSThierry Reding void tegra_output_remove(struct tegra_output *output); 146688c59afSThierry Reding int tegra_output_init(struct drm_device *drm, struct tegra_output *output); 147328ec69eSThierry Reding void tegra_output_exit(struct tegra_output *output); 148c57997bcSThierry Reding void tegra_output_find_possible_crtcs(struct tegra_output *output, 149c57997bcSThierry Reding struct drm_device *drm); 150fd67e9c6SThierry Reding int tegra_output_suspend(struct tegra_output *output); 151fd67e9c6SThierry Reding int tegra_output_resume(struct tegra_output *output); 152dee8268fSThierry Reding 153132085d8SThierry Reding int tegra_output_connector_get_modes(struct drm_connector *connector); 154132085d8SThierry Reding enum drm_connector_status 155132085d8SThierry Reding tegra_output_connector_detect(struct drm_connector *connector, bool force); 156132085d8SThierry Reding void tegra_output_connector_destroy(struct drm_connector *connector); 157132085d8SThierry Reding 1586b6b6042SThierry Reding /* from dpaux.c */ 1599542c237SThierry Reding struct drm_dp_aux *drm_dp_aux_find_by_of_node(struct device_node *np); 1609542c237SThierry Reding enum drm_connector_status drm_dp_aux_detect(struct drm_dp_aux *aux); 1619542c237SThierry Reding int drm_dp_aux_attach(struct drm_dp_aux *aux, struct tegra_output *output); 1629542c237SThierry Reding int drm_dp_aux_detach(struct drm_dp_aux *aux); 1639542c237SThierry Reding int drm_dp_aux_enable(struct drm_dp_aux *aux); 1649542c237SThierry Reding int drm_dp_aux_disable(struct drm_dp_aux *aux); 1656b6b6042SThierry Reding 166dee8268fSThierry Reding /* from fb.c */ 167dee8268fSThierry Reding struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer, 168dee8268fSThierry Reding unsigned int index); 169db7fbdfdSThierry Reding bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer); 170c134f019SThierry Reding int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer, 171c134f019SThierry Reding struct tegra_bo_tiling *tiling); 172f9914214SThierry Reding struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, 173f9914214SThierry Reding struct drm_file *file, 1741eb83451SVille Syrjälä const struct drm_mode_fb_cmd2 *cmd); 175e2215321SThierry Reding int tegra_drm_fb_prepare(struct drm_device *drm); 1761d1e6fe9SThierry Reding void tegra_drm_fb_free(struct drm_device *drm); 177688c59afSThierry Reding int tegra_drm_fb_init(struct drm_device *drm); 178688c59afSThierry Reding void tegra_drm_fb_exit(struct drm_device *drm); 179dee8268fSThierry Reding 180c4755fb9SThierry Reding extern struct platform_driver tegra_display_hub_driver; 181dee8268fSThierry Reding extern struct platform_driver tegra_dc_driver; 182dee8268fSThierry Reding extern struct platform_driver tegra_hdmi_driver; 183473112e4SThierry Reding extern struct platform_driver tegra_dsi_driver; 1846b6b6042SThierry Reding extern struct platform_driver tegra_dpaux_driver; 185473112e4SThierry Reding extern struct platform_driver tegra_sor_driver; 186dee8268fSThierry Reding extern struct platform_driver tegra_gr2d_driver; 1875f60ed0dSThierry Reding extern struct platform_driver tegra_gr3d_driver; 1880ae797a8SArto Merilainen extern struct platform_driver tegra_vic_driver; 189dee8268fSThierry Reding 190dee8268fSThierry Reding #endif /* HOST1X_DRM_H */ 191