hdmi:cec: delete maroc DEBUG definaion.
[firefly-linux-kernel-4.4.55.git] / drivers / video / rockchip / hdmi / rockchip-hdmi-cec.h
1 #ifndef __ROCKCHIP_HDMI_CEC_H__
2 #define __ROCKCHIP_HDMI_CEC_H__
3 #include "rockchip-hdmi.h"
4
5 #include <linux/input.h>
6 #include <linux/miscdevice.h>
7 enum {
8         CEC_LOGADDR_TV          = 0x00,
9         CEC_LOGADDR_RECDEV1     = 0x01,
10         CEC_LOGADDR_RECDEV2     = 0x02,
11         CEC_LOGADDR_TUNER1      = 0x03,     /* STB1 in Spev v1.3 */
12         CEC_LOGADDR_PLAYBACK1   = 0x04,     /* DVD1 in Spev v1.3 */
13         CEC_LOGADDR_AUDSYS      = 0x05,
14         CEC_LOGADDR_TUNER2      = 0x06,     /* STB2 in Spec v1.3 */
15         CEC_LOGADDR_TUNER3      = 0x07,     /* STB3 in Spec v1.3 */
16         CEC_LOGADDR_PLAYBACK2   = 0x08,     /* DVD2 in Spec v1.3 */
17         CEC_LOGADDR_RECDEV3     = 0x09,
18         CEC_LOGADDR_TUNER4      = 0x0A,     /* RES1 in Spec v1.3 */
19         CEC_LOGADDR_PLAYBACK3   = 0x0B,     /* RES2 in Spec v1.3 */
20         CEC_LOGADDR_RES3        = 0x0C,
21         CEC_LOGADDR_RES4        = 0x0D,
22         CEC_LOGADDR_FREEUSE     = 0x0E,
23         CEC_LOGADDR_UNREGORBC   = 0x0F
24
25 };
26
27 enum {                   /* CEC Messages */
28         CECOP_FEATURE_ABORT                     = 0x00,
29         CECOP_IMAGE_VIEW_ON                     = 0x04,
30         CECOP_TUNER_STEP_INCREMENT              = 0x05,
31         CECOP_TUNER_STEP_DECREMENT              = 0x06,
32         CECOP_TUNER_DEVICE_STATUS               = 0x07,
33         CECOP_GIVE_TUNER_DEVICE_STATUS          = 0x08,
34         CECOP_RECORD_ON                         = 0x09,
35         CECOP_RECORD_STATUS                     = 0x0A,
36         CECOP_RECORD_OFF                        = 0x0B,
37         CECOP_TEXT_VIEW_ON                      = 0x0D,
38         CECOP_RECORD_TV_SCREEN                  = 0x0F,
39         CECOP_GIVE_DECK_STATUS                  = 0x1A,
40         CECOP_DECK_STATUS                       = 0x1B,
41         CECOP_SET_MENU_LANGUAGE                 = 0x32,
42         CECOP_CLEAR_ANALOGUE_TIMER              = 0x33,     /* Spec 1.3A */
43         CECOP_SET_ANALOGUE_TIMER                = 0x34,     /* Spec 1.3A */
44         CECOP_TIMER_STATUS                      = 0x35,     /* Spec 1.3A */
45         CECOP_STANDBY                           = 0x36,
46         CECOP_PLAY                              = 0x41,
47         CECOP_DECK_CONTROL                      = 0x42,
48         CECOP_TIMER_CLEARED_STATUS              = 0x43,     /* Spec 1.3A */
49         CECOP_USER_CONTROL_PRESSED              = 0x44,
50         CECOP_USER_CONTROL_RELEASED             = 0x45,
51         CECOP_GIVE_OSD_NAME                     = 0x46,
52         CECOP_SET_OSD_NAME                      = 0x47,
53         CECOP_SET_OSD_STRING                    = 0x64,
54         CECOP_SET_TIMER_PROGRAM_TITLE           = 0x67, /* Spec 1.3A */
55         CECOP_SYSTEM_AUDIO_MODE_REQUEST         = 0x70, /* Spec 1.3A */
56         CECOP_GIVE_AUDIO_STATUS                 = 0x71, /* Spec 1.3A */
57         CECOP_SET_SYSTEM_AUDIO_MODE             = 0x72, /* Spec 1.3A */
58         CECOP_REPORT_AUDIO_STATUS               = 0x7A, /* Spec 1.3A */
59         CECOP_GIVE_SYSTEM_AUDIO_MODE_STATUS     = 0x7D, /* Spec 1.3A */
60         CECOP_SYSTEM_AUDIO_MODE_STATUS          = 0x7E, /* Spec 1.3A */
61         CECOP_ROUTING_CHANGE                    = 0x80,
62         CECOP_ROUTING_INFORMATION               = 0x81,
63         CECOP_ACTIVE_SOURCE                     = 0x82,
64         CECOP_GIVE_PHYSICAL_ADDRESS             = 0x83,
65         CECOP_REPORT_PHYSICAL_ADDRESS           = 0x84,
66         CECOP_REQUEST_ACTIVE_SOURCE             = 0x85,
67         CECOP_SET_STREAM_PATH                   = 0x86,
68         CECOP_DEVICE_VENDOR_ID                  = 0x87,
69         CECOP_VENDOR_COMMAND                    = 0x89,
70         CECOP_VENDOR_REMOTE_BUTTON_DOWN         = 0x8A,
71         CECOP_VENDOR_REMOTE_BUTTON_UP           = 0x8B,
72         CECOP_GIVE_DEVICE_VENDOR_ID             = 0x8C,
73         CECOP_MENU_REQUEST                      = 0x8D,
74         CECOP_MENU_STATUS                       = 0x8E,
75         CECOP_GIVE_DEVICE_POWER_STATUS          = 0x8F,
76         CECOP_REPORT_POWER_STATUS               = 0x90,
77         CECOP_GET_MENU_LANGUAGE                 = 0x91,
78         CECOP_SELECT_ANALOGUE_SERVICE           = 0x92,     /* Spec 1.3A */
79         CECOP_SELECT_DIGITAL_SERVICE            = 0x93,
80         CECOP_SET_DIGITAL_TIMER                 = 0x97,     /* Spec 1.3A */
81         CECOP_CLEAR_DIGITAL_TIMER               = 0x99,     /* Spec 1.3A */
82         CECOP_SET_AUDIO_RATE                    = 0x9A,     /* Spec 1.3A */
83         CECOP_INACTIVE_SOURCE                   = 0x9D,     /* Spec 1.3A */
84         CECOP_CEC_VERSION                       = 0x9E,     /* Spec 1.3A */
85         CECOP_GET_CEC_VERSION                   = 0x9F,     /* Spec 1.3A */
86         CECOP_VENDOR_COMMAND_WITH_ID            = 0xA0,     /* Spec 1.3A */
87         CECOP_CLEAR_EXTERNAL_TIMER              = 0xA1,     /* Spec 1.3A */
88         CECOP_SET_EXTERNAL_TIMER                = 0xA2,     /* Spec 1.3A */
89         CDCOP_HEADER                            = 0xF8,
90         CECOP_ABORT                             = 0xFF,
91
92         CECOP_REPORT_SHORT_AUDIO                = 0xA3,     /* Spec 1.4 */
93         CECOP_REQUEST_SHORT_AUDIO               = 0xA4,     /* Spec 1.4 */
94
95         CECOP_ARC_INITIATE                      = 0xC0,
96         CECOP_ARC_REPORT_INITIATED              = 0xC1,
97         CECOP_ARC_REPORT_TERMINATED             = 0xC2,
98
99         CECOP_ARC_REQUEST_INITIATION            = 0xC3,
100         CECOP_ARC_REQUEST_TERMINATION           = 0xC4,
101         CECOP_ARC_TERMINATE                     = 0xC5,
102
103 };
104
105 /* Operands for <Feature Abort> Opcode */
106 enum {
107         CECAR_UNRECOG_OPCODE            = 0x00,
108         CECAR_NOT_CORRECT_MODE,
109         CECAR_CANT_PROVIDE_SOURCE,
110         CECAR_INVALID_OPERAND,
111         CECAR_REFUSED
112 };
113
114 /* Operands for <Power Status> Opcode */
115 enum {
116         CEC_POWERSTATUS_ON              = 0x00,
117         CEC_POWERSTATUS_STANDBY         = 0x01,
118         CEC_POWERSTATUS_STANDBY_TO_ON   = 0x02,
119         CEC_POWERSTATUS_ON_TO_STANDBY   = 0x03,
120 };
121
122 enum {
123         EVENT_RX_FRAME,
124         EVENT_ENUMERATE,
125 };
126
127 enum {
128         CEC_SEND_SUCCESS = 0,
129         CEC_SEND_NACK,
130         CEC_SEND_BUSY
131 };
132
133 #define MAKE_SRCDEST(src, dest)    ((src << 4) | dest)
134
135 #define MAX_CMD_SIZE 16
136
137 struct cec_framedata {
138         char srcdestaddr; /* Source in upper nybble, dest in lower nybble */
139         char opcode;
140         char args[MAX_CMD_SIZE];
141         char argcount;
142         char returnval;
143 };
144
145 struct cec_delayed_work {
146         struct delayed_work work;
147         int event;
148         void *data;
149 };
150
151 struct cecframelist {
152         struct list_head framelist;
153         struct cec_framedata cecframe;
154 };
155
156 struct cec_device {
157         struct workqueue_struct *workqueue;
158         struct hdmi *hdmi;
159         struct miscdevice device;
160         int address_phy;
161         int address_logic;
162         int powerstatus;
163         int enable;
164         struct list_head ceclist;
165         struct mutex cec_lock;  /* mutex for hdmicec operation*/
166
167         int (*sendframe)(struct hdmi *, struct cec_framedata *);
168         int (*readframe)(struct hdmi *, struct cec_framedata *);
169         void (*setceclogicaddr)(struct hdmi *, int);
170 };
171
172 #ifdef DEBUG
173 #define CECDBG(format, ...) \
174                 pr_info(format, ## __VA_ARGS__)
175 #else
176 #define CECDBG(format, ...)
177 #endif
178 /* for HAL ioctl*/
179 #define HDMI_CEC_MAGIC     'N'
180 #define HDMI_IOCTL_CECSEND   _IOW(HDMI_CEC_MAGIC, 0, struct cec_framedata)
181 #define HDMI_IOCTL_CECENAB   _IOW(HDMI_CEC_MAGIC, 1, int)
182 #define HDMI_IOCTL_CECPHY    _IOR(HDMI_CEC_MAGIC, 2, int)
183 #define HDMI_IOCTL_CECLOGIC  _IOR(HDMI_CEC_MAGIC, 3, int)
184 #define HDMI_IOCTL_CECREAD   _IOR(HDMI_CEC_MAGIC, 4, struct cec_framedata)
185 #define HDMI_IOCTL_CECSETLA  _IOW(HDMI_CEC_MAGIC, 5, int)
186 #define HDMI_IOCTL_CECCLEARLA  _IOW(HDMI_CEC_MAGIC, 6, int)
187 /*for HAL ioctl end*/
188 int rockchip_hdmi_cec_init(struct hdmi *hdmi,
189                            int (*sendframe)(struct hdmi *,
190                                             struct cec_framedata *),
191                            int (*readframe)(struct hdmi *,
192                                             struct cec_framedata *),
193                            void (*setceclogicaddr)(struct hdmi *, int));
194 void rockchip_hdmi_cec_set_pa(int devpa);
195 void rockchip_hdmi_cec_submit_work(int event, int delay, void *data);
196 #endif /* __HDMI_CEC_H__ */