From 98179834cab3b2c1f8085c40f86860a21428c1ff Mon Sep 17 00:00:00 2001 From: Nanxin Qin Date: Fri, 14 Apr 2017 17:31:59 +0800 Subject: [PATCH] media: the regs r/w are removed in the module_init. PD#138714: fixed the crash when the os booting Change-Id: I0ffd67b9b85d06db9ffdae83a0cbc4c9bc8f6594 Signed-off-by: Nanxin Qin --- drivers/amlogic/media/frame_sync/ptsserv.c | 4 +- drivers/amlogic/media/frame_sync/tsync.c | 110 +++++++++---------------- drivers/amlogic/media/frame_sync/tsync_pcr.c | 4 - drivers/amlogic/media/video_sink/video.c | 11 +-- include/linux/amlogic/media/frame_sync/tsync.h | 2 + 5 files changed, 52 insertions(+), 79 deletions(-) diff --git a/drivers/amlogic/media/frame_sync/ptsserv.c b/drivers/amlogic/media/frame_sync/ptsserv.c index c3d50c3..0c8b724 100644 --- a/drivers/amlogic/media/frame_sync/ptsserv.c +++ b/drivers/amlogic/media/frame_sync/ptsserv.c @@ -36,7 +36,6 @@ #define INTERPOLATE_AUDIO_RESOLUTION 9000 #define PTS_VALID_OFFSET_TO_CHECK 0x08000000 - #define OFFSET_DIFF(x, y) ((int)(x - y)) #define OFFSET_LATER(x, y) (OFFSET_DIFF(x, y) > 0) #define OFFSET_EQLATER(x, y) (OFFSET_DIFF(x, y) >= 0) @@ -1122,6 +1121,9 @@ int pts_start(u8 type) ulong flags; struct pts_table_s *pTable; + /*tsync init.*/ + tsync_init(); + if (type >= PTS_TYPE_MAX) return -EINVAL; /* #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8 */ diff --git a/drivers/amlogic/media/frame_sync/tsync.c b/drivers/amlogic/media/frame_sync/tsync.c index be85d5f2..a132df3 100644 --- a/drivers/amlogic/media/frame_sync/tsync.c +++ b/drivers/amlogic/media/frame_sync/tsync.c @@ -66,6 +66,9 @@ MODULE_AMLOG(AMLOG_DEFAULT_LEVEL, 0, LOG_DEFAULT_LEVEL_DESC, #define PCR_MAINTAIN_MARGIN_SHIFT_VIDEO 1 #define PCR_RECOVER_PCR_ADJ 15 +#define TSYNC_INIT_STATE (0X01) +unsigned int tsync_flag; + enum { PCR_SYNC_UNSET, PCR_SYNC_HI, @@ -1130,6 +1133,34 @@ int tsync_set_apts(unsigned int pts) } EXPORT_SYMBOL(tsync_set_apts); +void tsync_init(void) +{ + if (tsync_flag & TSYNC_INIT_STATE) + return; + + tsync_flag |= TSYNC_INIT_STATE; + + /* init audio pts to -1, others to 0 */ + timestamp_apts_set(-1); + timestamp_vpts_set(0); + timestamp_pcrscr_set(0); + + init_timer(&tsync_pcr_recover_timer); + + tsync_pcr_recover_timer.function = tsync_pcr_recover_timer_func; + tsync_pcr_recover_timer.expires = jiffies + PCR_CHECK_INTERVAL; + pcr_sync_stat = PCR_SYNC_UNSET; + pcr_recover_trigger = 0; + + add_timer(&tsync_pcr_recover_timer); + + init_timer(&tsync_state_switch_timer); + tsync_state_switch_timer.function = tsync_state_switch_timer_fun; + tsync_state_switch_timer.expires = jiffies + 1; + + add_timer(&tsync_state_switch_timer); +} + /*********************************************************/ static ssize_t show_pcr_recover(struct class *class, @@ -1884,49 +1915,8 @@ static struct class tsync_class = { .name = "tsync", .class_attrs = tsync_class_attrs, }; -#if 0 -int tsync_init(void) -{ - int r; - - r = class_register(&tsync_class); - - if (r) { - amlog_level(LOG_LEVEL_ERROR, "tsync class create fail.\n"); - return r; - } - - /* init audio pts to -1, others to 0 */ - timestamp_apts_set(-1); - timestamp_vpts_set(0); - timestamp_pcrscr_set(0); - - init_timer(&tsync_pcr_recover_timer); - tsync_pcr_recover_timer.function = tsync_pcr_recover_timer_func; - tsync_pcr_recover_timer.expires = jiffies + PCR_CHECK_INTERVAL; - pcr_sync_stat = PCR_SYNC_UNSET; - pcr_recover_trigger = 0; - - add_timer(&tsync_pcr_recover_timer); - - init_timer(&tsync_state_switch_timer); - tsync_state_switch_timer.function = tsync_state_switch_timer_fun; - tsync_state_switch_timer.expires = jiffies + 1; - - add_timer(&tsync_state_switch_timer); - return 0; -} - -void tsync_exit(void) -{ - del_timer_sync(&tsync_pcr_recover_timer); - - class_unregister(&tsync_class); -} -#endif -#if 1 -static int __init tsync_init(void) +static int __init tsync_module_init(void) { int r; @@ -1937,42 +1927,24 @@ static int __init tsync_init(void) return r; } - /* init audio pts to -1, others to 0 */ - timestamp_apts_set(-1); - timestamp_vpts_set(0); - timestamp_pcrscr_set(0); - - init_timer(&tsync_pcr_recover_timer); - - tsync_pcr_recover_timer.function = tsync_pcr_recover_timer_func; - tsync_pcr_recover_timer.expires = jiffies + PCR_CHECK_INTERVAL; - pcr_sync_stat = PCR_SYNC_UNSET; - pcr_recover_trigger = 0; - - add_timer(&tsync_pcr_recover_timer); - - init_timer(&tsync_state_switch_timer); - tsync_state_switch_timer.function = tsync_state_switch_timer_fun; - tsync_state_switch_timer.expires = jiffies + 1; - - add_timer(&tsync_state_switch_timer); - - tsync_pcr_init();//DEBUG_TMP + tsync_pcr_init(); return 0; } -static void __exit tsync_exit(void) +static void __exit tsync_module_exit(void) { - del_timer_sync(&tsync_pcr_recover_timer); + if (tsync_flag & TSYNC_INIT_STATE) { + del_timer_sync(&tsync_pcr_recover_timer); + del_timer_sync(&tsync_state_switch_timer); + } class_unregister(&tsync_class); - tsync_pcr_exit();//DEBUG_TMP + tsync_pcr_exit(); } -module_init(tsync_init); -module_exit(tsync_exit); -#endif +module_init(tsync_module_init); +module_exit(tsync_module_exit); MODULE_DESCRIPTION("AMLOGIC time sync management driver"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Tim Yao "); diff --git a/drivers/amlogic/media/frame_sync/tsync_pcr.c b/drivers/amlogic/media/frame_sync/tsync_pcr.c index 08db56f..9af1ab3 100644 --- a/drivers/amlogic/media/frame_sync/tsync_pcr.c +++ b/drivers/amlogic/media/frame_sync/tsync_pcr.c @@ -1481,10 +1481,6 @@ int tsync_pcr_init(void) return r; } - /* init audio pts to -1, others to 0 */ - timestamp_apts_set(-1); - timestamp_vpts_set(0); - timestamp_pcrscr_set(0); wait_pcr_count = 0; pr_info("[tsync_pcr_init]init success.\n"); return 0; diff --git a/drivers/amlogic/media/video_sink/video.c b/drivers/amlogic/media/video_sink/video.c index 48dea96..f262d13 100644 --- a/drivers/amlogic/media/video_sink/video.c +++ b/drivers/amlogic/media/video_sink/video.c @@ -7911,6 +7911,11 @@ static int amvideom_probe(struct platform_device *pdev) { int ret = 0; + video_early_init(); + + DisableVideoLayer(); + DisableVideoLayer2(); + /* get interrupt resource */ video_vsync = platform_get_irq_byname(pdev, "vsync"); if (video_vsync == -ENXIO) { @@ -7955,7 +7960,7 @@ static int __init video_init(void) ulong clk = clk_get_rate(clk_get_sys("clk_misc_pll", NULL)); #endif */ - video_early_init(); + #ifdef CONFIG_ARCH_MESON1 no to here ulong clk = clk_get_rate(clk_get_sys("clk_other_pll", NULL)); @@ -7984,10 +7989,6 @@ static int __init video_init(void) return -ENODEV; } - - DisableVideoLayer(); - DisableVideoLayer2(); - /* check super scaler support status */ vpp_super_scaler_support(); /* adaptive config bypass ratio */ diff --git a/include/linux/amlogic/media/frame_sync/tsync.h b/include/linux/amlogic/media/frame_sync/tsync.h index 5fdaf95..bba553b 100644 --- a/include/linux/amlogic/media/frame_sync/tsync.h +++ b/include/linux/amlogic/media/frame_sync/tsync.h @@ -92,6 +92,8 @@ extern void tsync_set_sync_adiscont_diff(u32 discontinue_diff); extern void tsync_set_sync_vdiscont_diff(u32 discontinue_diff); extern int tsync_set_apts(unsigned int pts); +extern void tsync_init(void); + extern void tsync_set_automute_on(int automute_on); extern int tsync_get_debug_pts_checkin(void); -- 2.7.4