blob: 0818a9d1c1d6f76ec522cce19cb3089a4199cf5b [file] [log] [blame]
Dhaval Patel14d46ce2017-01-17 16:28:12 -08001/*
2 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
3 * Copyright (C) 2013 Red Hat
4 * Author: Rob Clark <robdclark@gmail.com>
Alan Kwong83285fb2016-10-21 20:51:17 -04005 *
Dhaval Patel14d46ce2017-01-17 16:28:12 -08006 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
Alan Kwong83285fb2016-10-21 20:51:17 -04009 *
Dhaval Patel14d46ce2017-01-17 16:28:12 -080010 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
Alan Kwong83285fb2016-10-21 20:51:17 -040017 */
18
19#ifndef __SDE_ENCODER_H__
20#define __SDE_ENCODER_H__
21
22#include <drm/drm_crtc.h>
23
24#include "msm_prop.h"
25#include "sde_hw_mdss.h"
26
27/**
28 * Encoder functions and data types
29 * @intfs: Interfaces this encoder is using, INTF_MODE_NONE if unused
30 * @wbs: Writebacks this encoder is using, INTF_MODE_NONE if unused
31 * @needs_cdm: Encoder requests a CDM based on pixel format conversion needs
32 * @display_num_of_h_tiles:
33 */
34struct sde_encoder_hw_resources {
35 enum sde_intf_mode intfs[INTF_MAX];
36 enum sde_intf_mode wbs[WB_MAX];
37 bool needs_cdm;
38 u32 display_num_of_h_tiles;
39};
40
41/**
42 * sde_encoder_get_hw_resources - Populate table of required hardware resources
43 * @encoder: encoder pointer
44 * @hw_res: resource table to populate with encoder required resources
45 * @conn_state: report hw reqs based on this proposed connector state
46 */
47void sde_encoder_get_hw_resources(struct drm_encoder *encoder,
48 struct sde_encoder_hw_resources *hw_res,
49 struct drm_connector_state *conn_state);
50
51/**
52 * sde_encoder_register_vblank_callback - provide callback to encoder that
53 * will be called on the next vblank.
54 * @encoder: encoder pointer
55 * @cb: callback pointer, provide NULL to deregister and disable IRQs
56 * @data: user data provided to callback
57 */
58void sde_encoder_register_vblank_callback(struct drm_encoder *encoder,
59 void (*cb)(void *), void *data);
60
61/**
62 * sde_encoder_schedule_kickoff - Register a callback with the encoder to
63 * trigger a double buffer flip of the ctl path (i.e. ctl flush and start)
64 * at the appropriate time.
65 * Immediately: if no previous commit is outstanding.
66 * Delayed: Save the callback, and return. Does not block. Callback will
67 * be triggered later. E.g. cmd encoder will trigger at pp_done irq
68 * irq if it outstanding.
69 * @encoder: encoder pointer
70 */
71void sde_encoder_schedule_kickoff(struct drm_encoder *encoder);
72
73/**
74 * sde_encoder_wait_nxt_committed - Wait for hardware to have flushed the
75 * current pending frames to hardware at a vblank or ctl_start
76 * Encoders will map this differently depending on irqs
77 * vid mode -> vsync_irq
78 * @encoder: encoder pointer
79 * Returns: 0 on success, -EWOULDBLOCK if already signaled, error otherwise
80 */
81int sde_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder);
82
83/**
84 * sde_encoder_init - initialize virtual encoder object
85 * @dev: Pointer to drm device structure
86 * @disp_info: Pointer to display information structure
87 * Returns: Pointer to newly created drm encoder
88 */
89struct drm_encoder *sde_encoder_init(
90 struct drm_device *dev,
91 struct msm_display_info *disp_info);
92
93/**
94 * sde_encoder_destroy - destroy previously initialized virtual encoder
95 * @drm_enc: Pointer to previously created drm encoder structure
96 */
97void sde_encoder_destroy(struct drm_encoder *drm_enc);
98
99#endif /* __SDE_ENCODER_H__ */