47
47
#include "mxc_hdmi-cec.h"
48
48
49
49
50
- #define MAX_MESSAGE_LEN 17
50
+ #define MAX_MESSAGE_LEN 17
51
51
52
- #define MESSAGE_TYPE_RECEIVE_SUCCESS 1
52
+ #define MESSAGE_TYPE_RECEIVE_SUCCESS 1
53
53
#define MESSAGE_TYPE_NOACK 2
54
- #define MESSAGE_TYPE_DISCONNECTED 3
54
+ #define MESSAGE_TYPE_DISCONNECTED 3
55
55
#define MESSAGE_TYPE_CONNECTED 4
56
- #define MESSAGE_TYPE_SEND_SUCCESS 5
56
+ #define MESSAGE_TYPE_SEND_SUCCESS 5
57
57
58
- #define CEC_TX_INPROGRESS -1
59
- #define CEC_TX_AVAIL 0
58
+ #define CEC_TX_INPROGRESS -1
59
+ #define CEC_TX_AVAIL 0
60
60
61
61
struct hdmi_cec_priv {
62
62
int receive_error ;
63
63
int send_error ;
64
64
u8 Logical_address ;
65
65
bool cec_state ;
66
- u8 last_msg [MAX_MESSAGE_LEN ];
67
- u8 msg_len ;
68
66
int tx_answer ;
69
67
u16 latest_cec_stat ;
70
68
u8 link_status ;
@@ -234,11 +232,6 @@ static void mxc_hdmi_cec_worker(struct work_struct *work)
234
232
hdmi_writeb (val , HDMI_IH_MUTE_CEC_STAT0 );
235
233
}
236
234
237
- /*!
238
- * @brief open function for cec file operation
239
- *
240
- * @return 0 on success or negative error code on error
241
- */
242
235
static int hdmi_cec_open (struct inode * inode , struct file * filp )
243
236
{
244
237
mutex_lock (& hdmi_cec_data .lock );
@@ -258,10 +251,9 @@ static ssize_t hdmi_cec_read(struct file *file, char __user *buf, size_t count,
258
251
loff_t * ppos )
259
252
{
260
253
struct hdmi_cec_event * event = NULL ;
254
+
261
255
pr_debug ("function : %s\n" , __func__ );
262
256
263
- if (!open_count )
264
- return - ENODEV ;
265
257
mutex_lock (& hdmi_cec_data .lock );
266
258
if (false == hdmi_cec_data .cec_state ) {
267
259
mutex_unlock (& hdmi_cec_data .lock );
@@ -303,8 +295,6 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
303
295
304
296
pr_debug ("function : %s\n" , __func__ );
305
297
306
- if (!open_count )
307
- return - ENODEV ;
308
298
mutex_lock (& hdmi_cec_data .lock );
309
299
if (false == hdmi_cec_data .cec_state ) {
310
300
mutex_unlock (& hdmi_cec_data .lock );
@@ -332,8 +322,6 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
332
322
val = hdmi_readb (HDMI_CEC_CTRL );
333
323
val |= 0x01 ;
334
324
hdmi_writeb (val , HDMI_CEC_CTRL );
335
- memcpy (hdmi_cec_data .last_msg , msg , msg_len );
336
- hdmi_cec_data .msg_len = msg_len ;
337
325
mutex_unlock (& hdmi_cec_data .lock );
338
326
339
327
ret = wait_event_interruptible_timeout (tx_cec_queue , hdmi_cec_data .tx_answer != CEC_TX_INPROGRESS , HZ );
@@ -347,9 +335,9 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
347
335
/* msg correctly sent */
348
336
ret = msg_len ;
349
337
else
350
- ret = - EIO ;
338
+ ret = - EIO ;
351
339
352
- tx_out :
340
+ tx_out :
353
341
hdmi_cec_data .tx_answer = CEC_TX_AVAIL ;
354
342
return ret ;
355
343
}
@@ -373,20 +361,15 @@ static void hdmi_stop_device(void)
373
361
mutex_unlock (& hdmi_cec_data .lock );
374
362
}
375
363
376
- /*!
377
- * @brief IO ctrl function for vpu file operation
378
- * @param cmd IO ctrl command
379
- * @return 0 on success or negative error code on error
380
- */
381
364
static long hdmi_cec_ioctl (struct file * filp , u_int cmd ,
382
365
u_long arg )
383
366
{
384
367
int ret = 0 , status = 0 ;
385
368
u8 val = 0 ;
386
369
struct mxc_edid_cfg hdmi_edid_cfg ;
370
+
387
371
pr_debug ("function : %s\n" , __func__ );
388
- if (!open_count )
389
- return - ENODEV ;
372
+
390
373
switch (cmd ) {
391
374
case HDMICEC_IOC_SETLOGICALADDRESS :
392
375
mutex_lock (& hdmi_cec_data .lock );
@@ -443,13 +426,12 @@ static long hdmi_cec_ioctl(struct file *filp, u_int cmd,
443
426
return ret ;
444
427
}
445
428
446
- /*!
447
- * @brief Release function for vpu file operation
448
- * @return 0 on success or negative error code on error
449
- */
450
429
static int hdmi_cec_release (struct inode * inode , struct file * filp )
451
430
{
452
431
struct hdmi_cec_event * event , * tmp_event ;
432
+
433
+ pr_debug ("function : %s\n" , __func__ );
434
+
453
435
mutex_lock (& hdmi_cec_data .lock );
454
436
if (open_count ) {
455
437
open_count = 0 ;
@@ -479,7 +461,7 @@ static unsigned int hdmi_cec_poll(struct file *file, poll_table *wait)
479
461
if (hdmi_cec_data .tx_answer == CEC_TX_AVAIL )
480
462
mask = (POLLOUT | POLLWRNORM );
481
463
if (!list_empty (& head ))
482
- mask |= (POLLIN | POLLRDNORM );
464
+ mask |= (POLLIN | POLLRDNORM );
483
465
mutex_unlock (& hdmi_cec_data .lock );
484
466
return mask ;
485
467
}
@@ -505,14 +487,14 @@ static int hdmi_cec_dev_probe(struct platform_device *pdev)
505
487
506
488
hdmi_cec_major = register_chrdev (hdmi_cec_major , "mxc_hdmi_cec" , & hdmi_cec_fops );
507
489
if (hdmi_cec_major < 0 ) {
508
- dev_err (& pdev -> dev , "hdmi_cec: unable to get a major for HDMI CEC\n" );
490
+ dev_err (& pdev -> dev , "Unable to get a major for HDMI CEC\n" );
509
491
err = - EBUSY ;
510
492
goto out ;
511
493
}
512
494
513
495
res = platform_get_resource (pdev , IORESOURCE_IRQ , 0 );
514
496
if (unlikely (res == NULL )) {
515
- dev_err (& pdev -> dev , "hdmi_cec: No HDMI irq line provided\n" );
497
+ dev_err (& pdev -> dev , "No HDMI irq line provided\n" );
516
498
goto err_out_chrdev ;
517
499
}
518
500
spin_lock_init (& hdmi_cec_data .irq_lock );
@@ -522,7 +504,7 @@ static int hdmi_cec_dev_probe(struct platform_device *pdev)
522
504
err = devm_request_irq (& pdev -> dev , irq , mxc_hdmi_cec_isr , IRQF_SHARED ,
523
505
dev_name (& pdev -> dev ), & hdmi_cec_data );
524
506
if (err < 0 ) {
525
- dev_err (& pdev -> dev , "hdmi_cec: Unable to request irq: %d\n" , err );
507
+ dev_err (& pdev -> dev , "Unable to request irq: %d\n" , err );
526
508
goto err_out_chrdev ;
527
509
}
528
510
@@ -532,16 +514,16 @@ static int hdmi_cec_dev_probe(struct platform_device *pdev)
532
514
goto err_out_chrdev ;
533
515
}
534
516
535
- temp_class = device_create (hdmi_cec_class , NULL , MKDEV ( hdmi_cec_major , 0 ),
536
- NULL , "mxc_hdmi_cec" );
517
+ temp_class = device_create (hdmi_cec_class , NULL ,
518
+ MKDEV ( hdmi_cec_major , 0 ), NULL , "mxc_hdmi_cec" );
537
519
if (IS_ERR (temp_class )) {
538
520
err = PTR_ERR (temp_class );
539
521
goto err_out_class ;
540
522
}
541
523
542
524
pinctrl = devm_pinctrl_get_select_default (& pdev -> dev );
543
525
if (IS_ERR (pinctrl )) {
544
- dev_err (& pdev -> dev , "can 't get/select CEC pinctrl\n" );
526
+ dev_err (& pdev -> dev , "Can 't get/select CEC pinctrl\n" );
545
527
goto err_out_class ;
546
528
}
547
529
@@ -569,14 +551,13 @@ static int hdmi_cec_dev_probe(struct platform_device *pdev)
569
551
570
552
static int hdmi_cec_dev_remove (struct platform_device * pdev )
571
553
{
572
- if (hdmi_cec_data .cec_state )
573
- hdmi_stop_device ();
574
- if (hdmi_cec_major > 0 ) {
575
- device_destroy (hdmi_cec_class , MKDEV (hdmi_cec_major , 0 ));
576
- class_destroy (hdmi_cec_class );
577
- unregister_chrdev (hdmi_cec_major , "mxc_hdmi_cec" );
578
- hdmi_cec_major = 0 ;
579
- }
554
+ hdmi_stop_device ();
555
+
556
+ device_destroy (hdmi_cec_class , MKDEV (hdmi_cec_major , 0 ));
557
+ class_destroy (hdmi_cec_class );
558
+ unregister_chrdev (hdmi_cec_major , "mxc_hdmi_cec" );
559
+ hdmi_cec_major = 0 ;
560
+
580
561
return 0 ;
581
562
}
582
563
@@ -590,9 +571,9 @@ static struct platform_driver mxc_hdmi_cec_driver = {
590
571
.probe = hdmi_cec_dev_probe ,
591
572
.remove = hdmi_cec_dev_remove ,
592
573
.driver = {
593
- .name = "mxc_hdmi_cec" ,
594
- .of_match_table = imx_hdmi_cec_match ,
595
- },
574
+ .name = "mxc_hdmi_cec" ,
575
+ .of_match_table = imx_hdmi_cec_match ,
576
+ },
596
577
};
597
578
598
579
module_platform_driver (mxc_hdmi_cec_driver );
0 commit comments