OSDN Git Service

lz4: fix wrong compress buffer size for 64-bits
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / linux / msm_ext_display.h
1 /* include/linux/msm_ext_display.h
2  *
3  * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 and
7  * only version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14 #ifndef _MSM_EXT_DISPLAY_H_
15 #define _MSM_EXT_DISPLAY_H_
16
17 #include <linux/device.h>
18 #include <linux/platform_device.h>
19
20 #define AUDIO_ACK_SET_ENABLE BIT(5)
21 #define AUDIO_ACK_ENABLE BIT(4)
22 #define AUDIO_ACK_CONNECT BIT(0)
23
24 /**
25  *  Flags to be used with the HPD operation of the external display
26  *  interface:
27  *  MSM_EXT_DISP_HPD_AUDIO: audio will be routed to external display
28  *  MSM_EXT_DISP_HPD_VIDEO: video will be routed to external display
29  *  MSM_EXT_DISP_HPD_ASYNC_AUDIO: don't wait audio notification once wake it up
30  *  MSM_EXT_DISP_HPD_ASYNC_VIDEO: don't wait video notification once wake it up
31  */
32 #define MSM_EXT_DISP_HPD_AUDIO BIT(0)
33 #define MSM_EXT_DISP_HPD_VIDEO BIT(1)
34 #define MSM_EXT_DISP_HPD_ASYNC_AUDIO BIT(2)
35 #define MSM_EXT_DISP_HPD_ASYNC_VIDEO BIT(3)
36
37 /**
38  * struct ext_disp_cable_notify - cable notify handler structure
39  * @link: a link for the linked list
40  * @status: current status of HDMI/DP cable connection
41  * @hpd_notify: callback function to provide cable status
42  */
43 struct ext_disp_cable_notify {
44         struct list_head link;
45         int status;
46         void (*hpd_notify)(struct ext_disp_cable_notify *h);
47 };
48
49 struct msm_ext_disp_audio_edid_blk {
50         u8 *audio_data_blk;
51         unsigned int audio_data_blk_size; /* in bytes */
52         u8 *spk_alloc_data_blk;
53         unsigned int spk_alloc_data_blk_size; /* in bytes */
54 };
55
56 struct msm_ext_disp_audio_setup_params {
57         u32 sample_rate_hz;
58         u32 num_of_channels;
59         u32 channel_allocation;
60         u32 level_shift;
61         bool down_mix;
62         u32 sample_present;
63 };
64
65 /**
66  * External Display identifier for use to determine which interface
67  * the audio driver is interacting with.
68  */
69 enum msm_ext_disp_type {
70         EXT_DISPLAY_TYPE_HDMI,
71         EXT_DISPLAY_TYPE_DP,
72         EXT_DISPLAY_TYPE_MAX
73 };
74
75 /**
76  * External Display cable state used by display interface to indicate
77  * connect/disconnect of interface.
78  */
79 enum msm_ext_disp_cable_state {
80         EXT_DISPLAY_CABLE_DISCONNECT,
81         EXT_DISPLAY_CABLE_CONNECT,
82         EXT_DISPLAY_CABLE_STATE_MAX
83 };
84
85 /**
86  * External Display power state used by display interface to indicate
87  * power on/off of the interface.
88  */
89 enum msm_ext_disp_power_state {
90         EXT_DISPLAY_POWER_OFF,
91         EXT_DISPLAY_POWER_ON,
92         EXT_DISPLAY_POWER_MAX
93 };
94
95 /**
96  * struct msm_ext_disp_intf_ops - operations exposed to display interface
97  * @hpd: updates external display interface state
98  * @notify: acknowledgment to power on or off
99  */
100 struct msm_ext_disp_intf_ops {
101         int (*hpd)(struct platform_device *pdev,
102                         enum msm_ext_disp_type type,
103                         enum msm_ext_disp_cable_state state,
104                         u32 flags);
105         int (*notify)(struct platform_device *pdev,
106                         enum msm_ext_disp_cable_state state);
107         int (*ack)(struct platform_device *pdev, u32 ack);
108 };
109
110 /**
111  * struct msm_ext_disp_audio_codec_ops - operations exposed to audio codec
112  * @audio_info_setup: configure audio on interface
113  * @get_audio_edid_blk: retrieve audio edid block
114  * @cable_status: cable connected/disconnected
115  * @get_intf_id: id of connected interface
116  * @acknowledge: acknowledge audio status
117  * @codec_ready: notify when codec is ready
118  */
119 struct msm_ext_disp_audio_codec_ops {
120         int (*audio_info_setup)(struct platform_device *pdev,
121                 struct msm_ext_disp_audio_setup_params *params);
122         int (*get_audio_edid_blk)(struct platform_device *pdev,
123                 struct msm_ext_disp_audio_edid_blk *blk);
124         int (*cable_status)(struct platform_device *pdev, u32 vote);
125         int (*get_intf_id)(struct platform_device *pdev);
126         void (*teardown_done)(struct platform_device *pdev);
127         int (*acknowledge)(struct platform_device *pdev, u32 ack);
128         void (*codec_ready)(struct platform_device *pdev);
129 };
130
131 /*
132  * struct msm_ext_disp_init_data - data needed to register the display interface
133  * @disp: external display type
134  * @intf_ops: external display interface operations
135  * @codec_ops: audio codec operations
136  */
137 struct msm_ext_disp_init_data {
138         enum msm_ext_disp_type type;
139         struct kobject *kobj;
140         struct msm_ext_disp_intf_ops intf_ops;
141         struct msm_ext_disp_audio_codec_ops codec_ops;
142         struct platform_device *pdev;
143 };
144
145 /*
146  * msm_ext_disp_register_audio_codec() - audio codec registration
147  * @pdev: platform device pointer
148  * @codec_ops: audio codec operations
149  */
150 int msm_ext_disp_register_audio_codec(struct platform_device *pdev,
151                 struct msm_ext_disp_audio_codec_ops *ops);
152
153 /*
154  * msm_hdmi_register_audio_codec() - wrapper for hdmi audio codec registration
155  * @pdev: platform device pointer
156  * @codec_ops: audio codec operations
157  */
158 int msm_hdmi_register_audio_codec(struct platform_device *pdev,
159         struct msm_ext_disp_audio_codec_ops *ops);
160 /*
161  * msm_ext_disp_register_intf() - display interface registration
162  * @init_data: data needed to register the display interface
163  */
164 int msm_ext_disp_register_intf(struct platform_device *pdev,
165                 struct msm_ext_disp_init_data *init_data);
166
167 #endif /*_MSM_EXT_DISPLAY_H_*/