75
75
HDMI_IH_CEC_STAT0_ARB_LOST)
76
76
77
77
struct hdmi_cec_priv {
78
- int receive_error ;
79
- int send_error ;
80
- u8 Logical_address ;
81
- u8 cec_state ;
78
+ int receive_error ;
79
+ int send_error ;
82
80
int tx_answer ;
83
81
u32 cec_stat0 ;
82
+ u8 logical_address ;
83
+ u8 is_started ;
84
84
u8 link_status ;
85
+ u8 open_count ;
85
86
spinlock_t irq_lock ;
86
87
struct work_struct hdmi_cec_work ;
87
88
struct mutex lock ;
@@ -95,19 +96,18 @@ struct hdmi_cec_event {
95
96
};
96
97
97
98
98
- static LIST_HEAD (head );
99
+ static LIST_HEAD (ev_pending );
99
100
100
101
static int hdmi_cec_irq ;
101
102
static int hdmi_cec_major ;
102
103
static struct class * hdmi_cec_class ;
103
104
static struct hdmi_cec_priv hdmi_cec_data ;
104
- static u8 open_count ;
105
105
static u8 want_start ;
106
106
static u8 link_status ;
107
107
static u8 is_initialized ;
108
108
109
- static wait_queue_head_t hdmi_cec_queue ;
110
- static wait_queue_head_t tx_cec_queue ;
109
+ static wait_queue_head_t rx_queue ;
110
+ static wait_queue_head_t tx_queue ;
111
111
112
112
static u32 get_hpd_stat (struct hdmi_cec_priv * hdmi_cec )
113
113
{
@@ -138,7 +138,7 @@ static irqreturn_t mxc_hdmi_cec_isr(int irq, void *data)
138
138
hdmi_writeb (cec_stat , HDMI_IH_CEC_STAT0 );
139
139
140
140
if ((cec_stat & ~CEC_STAT0_MASK_DEFAULT ) == 0 ) {
141
- if (hdmi_cec -> cec_state )
141
+ if (hdmi_cec -> is_started )
142
142
hdmi_writeb (CEC_STAT0_MASK_DEFAULT , HDMI_IH_MUTE_CEC_STAT0 );
143
143
spin_unlock_irqrestore (& hdmi_cec -> irq_lock , flags );
144
144
return IRQ_NONE ;
@@ -159,13 +159,13 @@ static void mxc_hdmi_cec_handle(u32 cec_stat)
159
159
u8 i = 0 ;
160
160
struct hdmi_cec_event * event = NULL ;
161
161
162
- if (!open_count )
162
+ if (!hdmi_cec_data . open_count )
163
163
return ;
164
164
165
165
/* The current transmission is successful (for initiator only). */
166
166
if (cec_stat & HDMI_IH_CEC_STAT0_DONE ) {
167
167
hdmi_cec_data .tx_answer = cec_stat ;
168
- wake_up (& tx_cec_queue );
168
+ wake_up (& tx_queue );
169
169
}
170
170
171
171
/*EOM is detected so that the received data is ready in the receiver data buffer*/
@@ -187,15 +187,15 @@ static void mxc_hdmi_cec_handle(u32 cec_stat)
187
187
event -> msg [i ] = hdmi_readb (HDMI_CEC_RX_DATA0 + i );
188
188
hdmi_writeb (0x0 , HDMI_CEC_LOCK );
189
189
mutex_lock (& hdmi_cec_data .lock );
190
- list_add_tail (& event -> list , & head );
190
+ list_add_tail (& event -> list , & ev_pending );
191
191
mutex_unlock (& hdmi_cec_data .lock );
192
- wake_up (& hdmi_cec_queue );
192
+ wake_up (& rx_queue );
193
193
}
194
194
195
195
/* An error is detected on cec line (for initiator only). */
196
196
if (cec_stat & HDMI_IH_CEC_STAT0_ERROR_INIT ) {
197
197
hdmi_cec_data .tx_answer = cec_stat ;
198
- wake_up (& tx_cec_queue );
198
+ wake_up (& tx_queue );
199
199
return ;
200
200
}
201
201
/* A frame is not acknowledged in a directly addressed message.
@@ -205,7 +205,7 @@ static void mxc_hdmi_cec_handle(u32 cec_stat)
205
205
if (cec_stat & HDMI_IH_CEC_STAT0_NACK ) {
206
206
hdmi_cec_data .send_error ++ ;
207
207
hdmi_cec_data .tx_answer = cec_stat ;
208
- wake_up (& tx_cec_queue );
208
+ wake_up (& tx_queue );
209
209
}
210
210
211
211
/* An error is notified by a follower.
@@ -227,9 +227,9 @@ static void mxc_hdmi_cec_handle(u32 cec_stat)
227
227
memset (event , 0 , sizeof (struct hdmi_cec_event ));
228
228
event -> event_type = MESSAGE_TYPE_CONNECTED ;
229
229
mutex_lock (& hdmi_cec_data .lock );
230
- list_add_tail (& event -> list , & head );
230
+ list_add_tail (& event -> list , & ev_pending );
231
231
mutex_unlock (& hdmi_cec_data .lock );
232
- wake_up (& hdmi_cec_queue );
232
+ wake_up (& rx_queue );
233
233
}
234
234
/*HDMI cable disconnected*/
235
235
if (cec_stat & CEC_STAT0_EX_DISCONNECTED ) {
@@ -242,9 +242,9 @@ static void mxc_hdmi_cec_handle(u32 cec_stat)
242
242
memset (event , 0 , sizeof (struct hdmi_cec_event ));
243
243
event -> event_type = MESSAGE_TYPE_DISCONNECTED ;
244
244
mutex_lock (& hdmi_cec_data .lock );
245
- list_add_tail (& event -> list , & head );
245
+ list_add_tail (& event -> list , & ev_pending );
246
246
mutex_unlock (& hdmi_cec_data .lock );
247
- wake_up (& hdmi_cec_queue );
247
+ wake_up (& rx_queue );
248
248
}
249
249
}
250
250
@@ -256,22 +256,22 @@ static void mxc_hdmi_cec_worker(struct work_struct *work)
256
256
257
257
spin_lock_irqsave (& hdmi_cec_data .irq_lock , flags );
258
258
hdmi_cec_data .cec_stat0 = 0 ;
259
- if (hdmi_cec_data .cec_state )
259
+ if (hdmi_cec_data .is_started )
260
260
hdmi_writeb (CEC_STAT0_MASK_DEFAULT , HDMI_IH_MUTE_CEC_STAT0 );
261
261
spin_unlock_irqrestore (& hdmi_cec_data .irq_lock , flags );
262
262
}
263
263
264
- static int hdmi_cec_open (struct inode * inode , struct file * filp )
264
+ static int hdmi_cec_open (struct inode * inode , struct file * file )
265
265
{
266
266
mutex_lock (& hdmi_cec_data .lock );
267
- if (open_count ) {
267
+ if (hdmi_cec_data . open_count ) {
268
268
mutex_unlock (& hdmi_cec_data .lock );
269
269
return - EBUSY ;
270
270
}
271
- open_count = 1 ;
272
- filp -> private_data = (void * )(& hdmi_cec_data );
273
- hdmi_cec_data .Logical_address = 15 ;
274
- hdmi_cec_data .cec_state = false;
271
+ hdmi_cec_data . open_count = 1 ;
272
+ file -> private_data = (void * )(& hdmi_cec_data );
273
+ hdmi_cec_data .logical_address = 15 ;
274
+ hdmi_cec_data .is_started = false;
275
275
mutex_unlock (& hdmi_cec_data .lock );
276
276
return 0 ;
277
277
}
@@ -284,26 +284,26 @@ static ssize_t hdmi_cec_read(struct file *file, char __user *buf, size_t count,
284
284
pr_debug ("function : %s\n" , __func__ );
285
285
286
286
mutex_lock (& hdmi_cec_data .lock );
287
- if (!hdmi_cec_data .cec_state ) {
287
+ if (!hdmi_cec_data .is_started ) {
288
288
mutex_unlock (& hdmi_cec_data .lock );
289
289
return - EACCES ;
290
290
}
291
291
292
- if (list_empty (& head )) {
292
+ if (list_empty (& ev_pending )) {
293
293
if (file -> f_flags & O_NONBLOCK ) {
294
294
mutex_unlock (& hdmi_cec_data .lock );
295
295
return - EAGAIN ;
296
296
} else {
297
297
do {
298
298
mutex_unlock (& hdmi_cec_data .lock );
299
- if (wait_event_interruptible (hdmi_cec_queue , ( !list_empty (& head ) )))
299
+ if (wait_event_interruptible (rx_queue , !list_empty (& ev_pending )))
300
300
return - ERESTARTSYS ;
301
301
mutex_lock (& hdmi_cec_data .lock );
302
- } while (list_empty (& head ));
302
+ } while (list_empty (& ev_pending ));
303
303
}
304
304
}
305
305
306
- event = list_first_entry (& head , struct hdmi_cec_event , list );
306
+ event = list_first_entry (& ev_pending , struct hdmi_cec_event , list );
307
307
list_del (& event -> list );
308
308
mutex_unlock (& hdmi_cec_data .lock );
309
309
if (copy_to_user (buf , event ,
@@ -320,19 +320,19 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
320
320
{
321
321
int ret = 0 ;
322
322
u8 i , msg_len , val ;
323
- u8 msg [MAX_MESSAGE_LEN ] = { 0 } ;
323
+ u8 msg [MAX_MESSAGE_LEN ];
324
324
325
325
pr_debug ("function : %s\n" , __func__ );
326
326
327
327
mutex_lock (& hdmi_cec_data .lock );
328
328
329
- if (!hdmi_cec_data .cec_state )
329
+ if (!hdmi_cec_data .is_started )
330
330
ret = - EACCES ;
331
331
else if (hdmi_cec_data .tx_answer != CEC_TX_AVAIL )
332
332
ret = - EBUSY ;
333
333
else if (count > MAX_MESSAGE_LEN )
334
334
ret = - EINVAL ;
335
- else if (copy_from_user (& msg , buf , count ))
335
+ else if (copy_from_user (msg , buf , count ))
336
336
ret = - EACCES ;
337
337
338
338
if (ret ) {
@@ -354,7 +354,7 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
354
354
mutex_unlock (& hdmi_cec_data .lock );
355
355
356
356
ret = wait_event_interruptible_timeout (
357
- tx_cec_queue , hdmi_cec_data .tx_answer != CEC_TX_INPROGRESS , HZ );
357
+ tx_queue , hdmi_cec_data .tx_answer != CEC_TX_INPROGRESS , HZ );
358
358
359
359
if (ret < 0 ) {
360
360
ret = - ERESTARTSYS ;
@@ -419,7 +419,7 @@ static void hdmi_cec_start_device(void)
419
419
hdmi_writeb (val , HDMI_CEC_MASK );
420
420
hdmi_writeb (val , HDMI_IH_MUTE_CEC_STAT0 );
421
421
hdmi_cec_data .link_status = link_status ;
422
- hdmi_cec_data .cec_state = true;
422
+ hdmi_cec_data .is_started = true;
423
423
424
424
spin_unlock_irqrestore (& hdmi_cec_data .irq_lock , flags );
425
425
}
@@ -436,7 +436,7 @@ static void hdmi_cec_stop_device(void)
436
436
437
437
spin_lock_irqsave (& hdmi_cec_data .irq_lock , flags );
438
438
439
- hdmi_cec_data .cec_state = false;
439
+ hdmi_cec_data .is_started = false;
440
440
hdmi_writeb (0x10 , HDMI_CEC_CTRL );
441
441
val = CEC_STAT0_MASK_ALL ;
442
442
hdmi_writeb (val , HDMI_CEC_MASK );
@@ -450,7 +450,7 @@ static void hdmi_cec_stop_device(void)
450
450
spin_unlock_irqrestore (& hdmi_cec_data .irq_lock , flags );
451
451
}
452
452
453
- static long hdmi_cec_ioctl (struct file * filp , u_int cmd ,
453
+ static long hdmi_cec_ioctl (struct file * file , u_int cmd ,
454
454
u_long arg )
455
455
{
456
456
int ret = 0 , status = 0 ;
@@ -462,18 +462,18 @@ static long hdmi_cec_ioctl(struct file *filp, u_int cmd,
462
462
switch (cmd ) {
463
463
case HDMICEC_IOC_SETLOGICALADDRESS :
464
464
mutex_lock (& hdmi_cec_data .lock );
465
- if (!hdmi_cec_data .cec_state ) {
465
+ if (!hdmi_cec_data .is_started ) {
466
466
mutex_unlock (& hdmi_cec_data .lock );
467
467
pr_err ("Trying to set logical address while not started\n" );
468
468
return - EACCES ;
469
469
}
470
- hdmi_cec_data .Logical_address = (u8 )arg ;
471
- if (hdmi_cec_data .Logical_address <= 7 ) {
472
- val = 1 << hdmi_cec_data .Logical_address ;
470
+ hdmi_cec_data .logical_address = (u8 )arg ;
471
+ if (hdmi_cec_data .logical_address <= 7 ) {
472
+ val = 1 << hdmi_cec_data .logical_address ;
473
473
hdmi_writeb (val , HDMI_CEC_ADDR_L );
474
474
hdmi_writeb (0 , HDMI_CEC_ADDR_H );
475
- } else if (hdmi_cec_data .Logical_address > 7 && hdmi_cec_data .Logical_address <= 15 ) {
476
- val = 1 << (hdmi_cec_data .Logical_address - 8 );
475
+ } else if (hdmi_cec_data .logical_address > 7 && hdmi_cec_data .logical_address <= 15 ) {
476
+ val = 1 << (hdmi_cec_data .logical_address - 8 );
477
477
hdmi_writeb (val , HDMI_CEC_ADDR_H );
478
478
hdmi_writeb (0 , HDMI_CEC_ADDR_L );
479
479
} else
@@ -501,20 +501,20 @@ static long hdmi_cec_ioctl(struct file *filp, u_int cmd,
501
501
return ret ;
502
502
}
503
503
504
- static int hdmi_cec_release (struct inode * inode , struct file * filp )
504
+ static int hdmi_cec_release (struct inode * inode , struct file * file )
505
505
{
506
506
struct hdmi_cec_event * event , * tmp_event ;
507
507
508
508
pr_debug ("function : %s\n" , __func__ );
509
509
510
510
mutex_lock (& hdmi_cec_data .lock );
511
- if (open_count ) {
512
- open_count = 0 ;
513
- hdmi_cec_data .cec_state = false;
514
- hdmi_cec_data .Logical_address = 15 ;
511
+ if (hdmi_cec_data . open_count ) {
512
+ hdmi_cec_data . open_count = 0 ;
513
+ hdmi_cec_data .is_started = false;
514
+ hdmi_cec_data .logical_address = 15 ;
515
515
516
516
/* Flush eventual events which have not been read by user space */
517
- list_for_each_entry_safe (event , tmp_event , & head , list ) {
517
+ list_for_each_entry_safe (event , tmp_event , & ev_pending , list ) {
518
518
list_del (& event -> list );
519
519
vfree (event );
520
520
}
@@ -530,12 +530,12 @@ static unsigned int hdmi_cec_poll(struct file *file, poll_table *wait)
530
530
531
531
pr_debug ("function : %s\n" , __func__ );
532
532
533
- poll_wait (file , & hdmi_cec_queue , wait );
533
+ poll_wait (file , & rx_queue , wait );
534
534
535
535
mutex_lock (& hdmi_cec_data .lock );
536
536
if (hdmi_cec_data .tx_answer == CEC_TX_AVAIL )
537
537
mask = (POLLOUT | POLLWRNORM );
538
- if (!list_empty (& head ))
538
+ if (!list_empty (& ev_pending ))
539
539
mask |= (POLLIN | POLLRDNORM );
540
540
mutex_unlock (& hdmi_cec_data .lock );
541
541
return mask ;
@@ -592,15 +592,15 @@ static int hdmi_cec_dev_probe(struct platform_device *pdev)
592
592
goto err_out_class ;
593
593
}
594
594
595
- INIT_LIST_HEAD (& head );
595
+ INIT_LIST_HEAD (& ev_pending );
596
596
597
- init_waitqueue_head (& hdmi_cec_queue );
598
- init_waitqueue_head (& tx_cec_queue );
597
+ init_waitqueue_head (& rx_queue );
598
+ init_waitqueue_head (& tx_queue );
599
599
600
600
mutex_init (& hdmi_cec_data .lock );
601
601
spin_lock_init (& hdmi_cec_data .irq_lock );
602
602
603
- hdmi_cec_data .Logical_address = 15 ;
603
+ hdmi_cec_data .logical_address = 15 ;
604
604
hdmi_cec_data .tx_answer = CEC_TX_AVAIL ;
605
605
INIT_WORK (& hdmi_cec_data .hdmi_cec_work , mxc_hdmi_cec_worker );
606
606
0 commit comments