@@ -52,20 +52,23 @@ static int early_suspend_flag;
52
52
static int early_resume_flag ;
53
53
#endif
54
54
55
+ #define VOUT_CDEV_NAME "display"
55
56
#define VOUT_CLASS_NAME "display"
56
57
#define MAX_NUMBER_PARA 10
57
58
59
+ #define VMODE_NAME_LEN_MAX 64
58
60
static struct class * vout_class ;
59
61
static DEFINE_MUTEX (vout_mutex );
60
- static char vout_mode_uboot [64 ] __nosavedata ;
61
- static char vout_mode [64 ] __nosavedata ;
62
+ static char vout_mode_uboot [VMODE_NAME_LEN_MAX ] __nosavedata ;
63
+ static char vout_mode [VMODE_NAME_LEN_MAX ] __nosavedata ;
64
+ static char local_name [VMODE_NAME_LEN_MAX ] = {0 };
62
65
static u32 vout_init_vmode = VMODE_INIT_NULL ;
63
66
static int uboot_display ;
64
67
65
68
static char vout_axis [64 ] __nosavedata ;
66
69
67
- static char hdmimode [64 ];
68
- static char cvbsmode [64 ];
70
+ static char hdmimode [VMODE_NAME_LEN_MAX ];
71
+ static char cvbsmode [VMODE_NAME_LEN_MAX ];
69
72
static enum vmode_e last_vmode = VMODE_MAX ;
70
73
static int tvout_monitor_flag = 1 ;
71
74
static unsigned int tvout_monitor_timeout_cnt = 20 ;
@@ -75,7 +78,7 @@ static struct delayed_work tvout_mode_work;
75
78
void update_vout_mode (char * name )
76
79
{
77
80
if (name )
78
- snprintf (vout_mode , 60 , "%s" , name );
81
+ snprintf (vout_mode , VMODE_NAME_LEN_MAX , "%s" , name );
79
82
else
80
83
VOUTERR ("%s: vout mode is null\n" , __func__ );
81
84
}
@@ -93,28 +96,25 @@ char *get_vout_mode_uboot(void)
93
96
}
94
97
EXPORT_SYMBOL (get_vout_mode_uboot );
95
98
96
- static char local_name [32 ] = {0 };
97
-
98
99
static int set_vout_mode (char * name )
99
100
{
100
101
enum vmode_e mode ;
101
102
int ret = 0 ;
102
103
103
104
VOUTPR ("vmode set to %s\n" , name );
104
105
105
- mode = validate_vmode (name );
106
- if (mode == VMODE_MAX ) {
107
- VOUTERR ("no matched vout mode\n" );
108
- return -1 ;
109
- }
110
-
111
106
if (strcmp (name , local_name ) == 0 ) {
112
107
VOUTPR ("don't set the same mode as current\n" );
113
108
return -1 ;
114
109
}
115
110
111
+ mode = validate_vmode (name );
112
+ if (mode == VMODE_MAX ) {
113
+ VOUTERR ("no matched vout mode\n" );
114
+ return -1 ;
115
+ }
116
116
memset (local_name , 0 , sizeof (local_name ));
117
- strcpy (local_name , name );
117
+ snprintf (local_name , VMODE_NAME_LEN_MAX , "%s" , name );
118
118
119
119
vout_notifier_call_chain (VOUT_EVENT_MODE_CHANGE_PRE , & mode );
120
120
ret = set_current_vmode (mode );
@@ -146,7 +146,7 @@ static int set_vout_init_mode(void)
146
146
vmode = vout_init_vmode ;
147
147
148
148
memset (local_name , 0 , sizeof (local_name ));
149
- strcpy (local_name , vout_mode_uboot );
149
+ snprintf (local_name , VMODE_NAME_LEN_MAX , "%s" , vout_mode_uboot );
150
150
ret = set_current_vmode (vmode );
151
151
VOUTPR ("init mode %s\n" , vout_mode_uboot );
152
152
@@ -194,17 +194,19 @@ static int parse_para(const char *para, int para_num, int *result)
194
194
static void set_vout_axis (char * para )
195
195
{
196
196
static struct disp_rect_s disp_rect [OSD_COUNT ];
197
- char count = OSD_COUNT * 4 ;
197
+ /* char count = OSD_COUNT * 4; */
198
198
int * pt = & disp_rect [0 ].x ;
199
199
int parsed [MAX_NUMBER_PARA ] = {};
200
200
201
201
/* parse window para */
202
202
if (parse_para (para , 8 , parsed ) >= 4 )
203
203
memcpy (pt , parsed , sizeof (struct disp_rect_s ) * OSD_COUNT );
204
- if ((count >= 4 ) && (count < 8 ))
205
- disp_rect [1 ] = disp_rect [0 ];
204
+ /* if ((count >= 4) && (count < 8))
205
+ * disp_rect[1] = disp_rect[0];
206
+ */
206
207
207
- VOUTPR ("osd0=> x:%d,y:%d,w:%d,h:%d\nosd1=> x:%d,y:%d,w:%d,h:%d\n" ,
208
+ VOUTPR ("osd0=> x:%d,y:%d,w:%d,h:%d\n"
209
+ "osd1=> x:%d,y:%d,w:%d,h:%d\n" ,
208
210
* pt , * (pt + 1 ), * (pt + 2 ), * (pt + 3 ),
209
211
* (pt + 4 ), * (pt + 5 ), * (pt + 6 ), * (pt + 7 ));
210
212
vout_notifier_call_chain (VOUT_EVENT_OSD_DISP_AXIS , & disp_rect [0 ]);
@@ -215,7 +217,7 @@ static ssize_t vout_mode_show(struct class *class,
215
217
{
216
218
int ret = 0 ;
217
219
218
- ret = snprintf (buf , 64 , "%s\n" , vout_mode );
220
+ ret = snprintf (buf , VMODE_NAME_LEN_MAX , "%s\n" , vout_mode );
219
221
220
222
return ret ;
221
223
}
@@ -227,9 +229,9 @@ static ssize_t vout_mode_store(struct class *class,
227
229
228
230
mutex_lock (& vout_mutex );
229
231
tvout_monitor_flag = 0 ;
230
- snprintf (mode , 64 , "%s" , buf );
232
+ snprintf (mode , VMODE_NAME_LEN_MAX , "%s" , buf );
231
233
if (set_vout_mode (mode ) == 0 )
232
- strcpy (vout_mode , mode );
234
+ snprintf (vout_mode , VMODE_NAME_LEN_MAX , "%s\n" , mode );
233
235
mutex_unlock (& vout_mutex );
234
236
return count ;
235
237
}
@@ -273,15 +275,16 @@ static ssize_t vout_fr_policy_store(struct class *class,
273
275
274
276
mutex_lock (& vout_mutex );
275
277
ret = kstrtoint (buf , 10 , & policy );
276
- if (ret == 1 ) {
277
- ret = set_vframe_rate_policy (policy );
278
- if (ret )
279
- pr_info ("%s: %d failed\n" , __func__ , policy );
280
- } else {
278
+ if (ret ) {
281
279
pr_info ("%s: invalid data\n" , __func__ );
280
+ mutex_unlock (& vout_mutex );
282
281
return - EINVAL ;
283
282
}
283
+ ret = set_vframe_rate_policy (policy );
284
+ if (ret )
285
+ pr_info ("%s: %d failed\n" , __func__ , policy );
284
286
mutex_unlock (& vout_mutex );
287
+
285
288
return count ;
286
289
}
287
290
@@ -316,7 +319,7 @@ static ssize_t vout_vinfo_show(struct class *class,
316
319
info -> sync_duration_num , info -> sync_duration_den ,
317
320
info -> screen_real_width , info -> screen_real_height ,
318
321
info -> video_clk , info -> viu_color_fmt , info -> viu_mux );
319
- len += sprintf (buf + len , "hdr_info :\n"
322
+ len += sprintf (buf + len , "master_display_info :\n"
320
323
" present_flag %d\n"
321
324
" features 0x%x\n"
322
325
" primaries 0x%x, 0x%x\n"
@@ -355,13 +358,11 @@ static ssize_t vout_mode_flag_store(struct class *class,
355
358
int ret = 0 ;
356
359
357
360
ret = kstrtoint (buf , 10 , & tvout_monitor_flag );
358
- if (ret == 1 ) {
359
- VOUTPR ("%s: tvout_monitor_flag = %d\n" ,
360
- __func__ , tvout_monitor_flag );
361
- } else {
361
+ if (ret ) {
362
362
VOUTPR ("%s: invalid data\n" , __func__ );
363
363
return - EINVAL ;
364
364
}
365
+ VOUTPR ("%s: tvout_monitor_flag = %d\n" , __func__ , tvout_monitor_flag );
365
366
366
367
return count ;
367
368
}
@@ -371,8 +372,8 @@ static struct class_attribute vout_class_attrs[] = {
371
372
__ATTR (axis , 0644 , vout_axis_show , vout_axis_store ),
372
373
__ATTR (fr_policy , 0644 ,
373
374
vout_fr_policy_show , vout_fr_policy_store ),
374
- __ATTR (vinfo , 0644 , vout_vinfo_show , NULL ),
375
- __ATTR (mode_flag , 0644 , vout_mode_flag_show , vout_mode_flag_store ),
375
+ __ATTR (vinfo , 0444 , vout_vinfo_show , NULL ),
376
+ __ATTR (mode_flag , 0644 , vout_mode_flag_show , vout_mode_flag_store ),
376
377
};
377
378
378
379
static int vout_create_attr (void )
@@ -399,7 +400,7 @@ static int vout_create_attr(void)
399
400
/* init /sys/class/display/mode */
400
401
init_mode = get_current_vinfo ();
401
402
if (init_mode )
402
- strcpy (vout_mode , init_mode -> name );
403
+ snprintf (vout_mode , VMODE_NAME_LEN_MAX , "%s" , init_mode -> name );
403
404
404
405
return ret ;
405
406
}
@@ -554,8 +555,10 @@ static int refresh_tvout_mode(void)
554
555
555
556
if (cur_vmode != last_vmode ) {
556
557
VOUTPR ("%s: mode chang\n" , __func__ );
557
- if (set_vout_mode (cur_mode_str ) == 0 )
558
- strcpy (vout_mode , cur_mode_str );
558
+ if (set_vout_mode (cur_mode_str ) == 0 ) {
559
+ snprintf (vout_mode , VMODE_NAME_LEN_MAX ,
560
+ "%s" , cur_mode_str );
561
+ }
559
562
last_vmode = cur_vmode ;
560
563
}
561
564
@@ -639,6 +642,12 @@ static int aml_vout_remove(struct platform_device *pdev)
639
642
return 0 ;
640
643
}
641
644
645
+ static void aml_vout_shutdown (struct platform_device * pdev )
646
+ {
647
+ VOUTPR ("%s\n" , __func__ );
648
+ vout_shutdown ();
649
+ }
650
+
642
651
static const struct of_device_id aml_vout_dt_match [] = {
643
652
{ .compatible = "amlogic, vout" ,},
644
653
{ },
@@ -657,6 +666,7 @@ const struct dev_pm_ops vout_pm = {
657
666
static struct platform_driver vout_driver = {
658
667
.probe = aml_vout_probe ,
659
668
.remove = aml_vout_remove ,
669
+ .shutdown = aml_vout_shutdown ,
660
670
#ifdef CONFIG_PM
661
671
.suspend = aml_vout_suspend ,
662
672
.resume = aml_vout_resume ,
@@ -674,8 +684,6 @@ static int __init vout_init_module(void)
674
684
{
675
685
int ret = 0 ;
676
686
677
- /*VOUTPR("%s\n", __func__);*/
678
-
679
687
if (platform_driver_register (& vout_driver )) {
680
688
VOUTERR ("failed to register VOUT driver\n" );
681
689
ret = - ENODEV ;
@@ -686,7 +694,6 @@ static int __init vout_init_module(void)
686
694
687
695
static __exit void vout_exit_module (void )
688
696
{
689
- /*VOUTPR("%s\n", __func__);*/
690
697
platform_driver_unregister (& vout_driver );
691
698
}
692
699
@@ -715,7 +722,8 @@ static void vout_init_mode_parse(char *str)
715
722
uboot_display = 1 ;
716
723
VOUTPR ("%s: %d\n" , str , uboot_display );
717
724
return ;
718
- } else if (strncmp (str , "dis" , 3 ) == 0 ) { /* disable */
725
+ }
726
+ if (strncmp (str , "dis" , 3 ) == 0 ) { /* disable */
719
727
uboot_display = 0 ;
720
728
VOUTPR ("%s: %d\n" , str , uboot_display );
721
729
return ;
@@ -725,12 +733,8 @@ static void vout_init_mode_parse(char *str)
725
733
* just save the vmode_name,
726
734
* convert to vmode when vout sever registered
727
735
*/
728
- strcpy (vout_mode_uboot , str );
736
+ snprintf (vout_mode_uboot , VMODE_NAME_LEN_MAX , "%s" , str );
729
737
VOUTPR ("%s\n" , str );
730
-
731
- return ;
732
-
733
- VOUTERR ("%s: %s\n" , __func__ , str );
734
738
}
735
739
736
740
static int __init get_vout_init_mode (char * str )
@@ -770,21 +774,21 @@ __setup("vout=", get_vout_init_mode);
770
774
771
775
static int __init get_hdmi_mode (char * str )
772
776
{
773
- strcpy (hdmimode , str );
777
+ snprintf (hdmimode , VMODE_NAME_LEN_MAX , "%s" , str );
774
778
775
- VOUTPR ("get hdmimode: %s\n" , str );
776
- return 1 ;
779
+ VOUTPR ("get hdmimode: %s\n" , hdmimode );
780
+ return 0 ;
777
781
}
778
782
__setup ("hdmimode=" , get_hdmi_mode );
779
783
780
784
static int __init get_cvbs_mode (char * str )
781
785
{
782
786
if ((strncmp ("480" , str , 3 ) == 0 ) || (strncmp ("576" , str , 3 ) == 0 ))
783
- strcpy (cvbsmode , str );
787
+ snprintf (cvbsmode , VMODE_NAME_LEN_MAX , "%s" , str );
784
788
else if (strncmp ("nocvbs" , str , 6 ) == 0 )
785
- strcpy (cvbsmode , "invalid" );
786
- VOUTPR ("get cvbsmode: %s\n" , str );
787
- return 1 ;
789
+ snprintf (cvbsmode , VMODE_NAME_LEN_MAX , "invalid" );
790
+ VOUTPR ("get cvbsmode: %s\n" , cvbsmode );
791
+ return 0 ;
788
792
}
789
793
__setup ("cvbsmode=" , get_cvbs_mode );
790
794
0 commit comments