Tatenda Chipeperekwa | 326526e | 2017-04-24 16:51:50 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _MSM_EXT_DISPLAY_H_ |
| 14 | #define _MSM_EXT_DISPLAY_H_ |
| 15 | |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/extcon.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 | */ |
| 30 | #define MSM_EXT_DISP_HPD_AUDIO BIT(0) |
| 31 | #define MSM_EXT_DISP_HPD_VIDEO BIT(1) |
| 32 | |
| 33 | /** |
| 34 | * struct ext_disp_cable_notify - cable notify handler structure |
| 35 | * @link: a link for the linked list |
| 36 | * @status: current status of HDMI/DP cable connection |
| 37 | * @hpd_notify: callback function to provide cable status |
| 38 | */ |
| 39 | struct ext_disp_cable_notify { |
| 40 | struct list_head link; |
| 41 | int status; |
| 42 | void (*hpd_notify)(struct ext_disp_cable_notify *h); |
| 43 | }; |
| 44 | |
| 45 | struct msm_ext_disp_audio_edid_blk { |
| 46 | u8 *audio_data_blk; |
| 47 | unsigned int audio_data_blk_size; /* in bytes */ |
| 48 | u8 *spk_alloc_data_blk; |
| 49 | unsigned int spk_alloc_data_blk_size; /* in bytes */ |
| 50 | }; |
| 51 | |
| 52 | struct msm_ext_disp_audio_setup_params { |
| 53 | u32 sample_rate_hz; |
| 54 | u32 num_of_channels; |
| 55 | u32 channel_allocation; |
| 56 | u32 level_shift; |
| 57 | bool down_mix; |
| 58 | u32 sample_present; |
| 59 | }; |
| 60 | |
| 61 | /* |
| 62 | * External Display identifier for use to determine which interface |
| 63 | * the audio driver is interacting with. |
| 64 | */ |
| 65 | enum msm_ext_disp_type { |
| 66 | EXT_DISPLAY_TYPE_HDMI = EXTCON_DISP_HDMI, |
| 67 | EXT_DISPLAY_TYPE_DP = EXTCON_DISP_DP, |
| 68 | EXT_DISPLAY_TYPE_MAX = 0xFFFFFFFF |
| 69 | }; |
| 70 | |
| 71 | /* |
| 72 | * External Display cable state used by display interface to indicate |
| 73 | * connect/disconnect of interface. |
| 74 | */ |
| 75 | enum msm_ext_disp_cable_state { |
| 76 | EXT_DISPLAY_CABLE_DISCONNECT, |
| 77 | EXT_DISPLAY_CABLE_CONNECT, |
| 78 | EXT_DISPLAY_CABLE_STATE_MAX |
| 79 | }; |
| 80 | |
| 81 | /** |
| 82 | * External Display power state used by display interface to indicate |
| 83 | * power on/off of the interface. |
| 84 | */ |
| 85 | enum msm_ext_disp_power_state { |
| 86 | EXT_DISPLAY_POWER_OFF, |
| 87 | EXT_DISPLAY_POWER_ON, |
| 88 | EXT_DISPLAY_POWER_MAX |
| 89 | }; |
| 90 | |
| 91 | /** |
| 92 | * struct msm_ext_disp_intf_ops - operations exposed to display interface |
| 93 | * @audio_config: configures the audio operations exposed to codec driver |
| 94 | * @audio_notify: notifies the audio connection state to user modules. |
| 95 | * @video_notify: notifies the video connection state to user modules. |
| 96 | */ |
| 97 | struct msm_ext_disp_intf_ops { |
| 98 | int (*audio_config)(struct platform_device *pdev, |
| 99 | enum msm_ext_disp_type type, |
| 100 | enum msm_ext_disp_cable_state state); |
| 101 | |
| 102 | int (*audio_notify)(struct platform_device *pdev, |
| 103 | enum msm_ext_disp_type type, |
| 104 | enum msm_ext_disp_cable_state state); |
| 105 | |
| 106 | |
| 107 | int (*video_notify)(struct platform_device *pdev, |
| 108 | enum msm_ext_disp_type type, |
| 109 | enum msm_ext_disp_cable_state state); |
| 110 | }; |
| 111 | |
| 112 | /** |
| 113 | * struct msm_ext_disp_audio_codec_ops - operations exposed to audio codec |
| 114 | * @audio_info_setup: configure audio on interface |
| 115 | * @get_audio_edid_blk: retrieve audio edid block |
| 116 | * @cable_status: cable connected/disconnected |
| 117 | * @get_intf_id: id of connected interface |
| 118 | * @teardown_done: audio session teardown done by qdsp |
| 119 | * @acknowledge: acknowledge audio status received by user modules |
Tatenda Chipeperekwa | dee24ac | 2017-10-26 18:04:33 -0700 | [diff] [blame] | 120 | * @ready: notify audio when codec driver is ready. |
Tatenda Chipeperekwa | 326526e | 2017-04-24 16:51:50 -0700 | [diff] [blame] | 121 | */ |
| 122 | struct msm_ext_disp_audio_codec_ops { |
| 123 | int (*audio_info_setup)(struct platform_device *pdev, |
| 124 | struct msm_ext_disp_audio_setup_params *params); |
| 125 | int (*get_audio_edid_blk)(struct platform_device *pdev, |
| 126 | struct msm_ext_disp_audio_edid_blk *blk); |
| 127 | int (*cable_status)(struct platform_device *pdev, u32 vote); |
| 128 | int (*get_intf_id)(struct platform_device *pdev); |
| 129 | void (*teardown_done)(struct platform_device *pdev); |
| 130 | int (*acknowledge)(struct platform_device *pdev, u32 ack); |
Tatenda Chipeperekwa | dee24ac | 2017-10-26 18:04:33 -0700 | [diff] [blame] | 131 | int (*ready)(struct platform_device *pdev); |
Tatenda Chipeperekwa | 326526e | 2017-04-24 16:51:50 -0700 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | /** |
| 135 | * struct msm_ext_disp_init_data - data needed to register a display interface |
| 136 | * @type: external display type |
| 137 | * @intf_ops: external display interface operations |
| 138 | * @codec_ops: audio codec operations |
| 139 | * @pdev: platform device instance of the interface driver |
| 140 | * @intf_data: interface specific data |
| 141 | */ |
| 142 | struct msm_ext_disp_init_data { |
| 143 | enum msm_ext_disp_type type; |
| 144 | struct msm_ext_disp_intf_ops intf_ops; |
| 145 | struct msm_ext_disp_audio_codec_ops codec_ops; |
| 146 | struct platform_device *pdev; |
| 147 | void *intf_data; |
| 148 | }; |
| 149 | |
| 150 | /** |
| 151 | * struct msm_ext_disp_data - data needed by interface modules |
| 152 | * @intf_pdev: platform device instance of the interface |
| 153 | * @intf_data: data related to interface module |
| 154 | */ |
| 155 | struct msm_ext_disp_data { |
| 156 | struct platform_device *intf_pdev; |
| 157 | void *intf_data; |
| 158 | }; |
| 159 | |
| 160 | /** |
| 161 | * msm_ext_disp_register_audio_codec() - audio codec registration |
| 162 | * @pdev: platform device pointer |
| 163 | * @codec_ops: audio codec operations |
| 164 | */ |
| 165 | int msm_ext_disp_register_audio_codec(struct platform_device *pdev, |
| 166 | struct msm_ext_disp_audio_codec_ops *ops); |
| 167 | |
| 168 | /** |
| 169 | * msm_hdmi_register_audio_codec() - wrapper for hdmi audio codec |
| 170 | * registration |
| 171 | * @pdev: platform device pointer |
| 172 | * @codec_ops: audio codec operations |
| 173 | */ |
| 174 | int msm_hdmi_register_audio_codec(struct platform_device *pdev, |
| 175 | struct msm_ext_disp_audio_codec_ops *ops); |
| 176 | |
| 177 | /** |
| 178 | * msm_ext_disp_register_intf() - display interface registration |
| 179 | * @init_data: data needed to register the display interface |
| 180 | */ |
| 181 | int msm_ext_disp_register_intf(struct platform_device *pdev, |
| 182 | struct msm_ext_disp_init_data *init_data); |
| 183 | |
| 184 | #endif /*_MSM_EXT_DISPLAY_H_*/ |