[PATCH 0/2] add support for Spreadtrum's FM driver
[add linux-media list and Mauro Carvalho Chehab] According to GregKH's suggestion [1], we tried to simply sort out the FM driver source code which has been using in the internal projects. Hopes it can help for fixing the problem raised in [1]. [1] https://lkml.org/lkml/2017/6/28/222 Chunyan Zhang (2): arm64: dts: add Spreadtrum's fm support misc: added Spreadtrum's radio driver arch/arm64/boot/dts/sprd/sp9860g-1h10.dts |4 + drivers/misc/Kconfig |1 + drivers/misc/Makefile |1 + drivers/misc/sprd-wcn/Kconfig | 14 + drivers/misc/sprd-wcn/Makefile |1 + drivers/misc/sprd-wcn/radio/Kconfig|8 + drivers/misc/sprd-wcn/radio/Makefile |2 + drivers/misc/sprd-wcn/radio/fmdrv.h| 595 +++ drivers/misc/sprd-wcn/radio/fmdrv_main.c | 1245 drivers/misc/sprd-wcn/radio/fmdrv_main.h | 117 +++ drivers/misc/sprd-wcn/radio/fmdrv_ops.c| 447 + drivers/misc/sprd-wcn/radio/fmdrv_ops.h| 17 + drivers/misc/sprd-wcn/radio/fmdrv_rds_parser.c | 753 ++ drivers/misc/sprd-wcn/radio/fmdrv_rds_parser.h | 103 ++ 14 files changed, 3308 insertions(+) create mode 100644 drivers/misc/sprd-wcn/Kconfig create mode 100644 drivers/misc/sprd-wcn/Makefile create mode 100644 drivers/misc/sprd-wcn/radio/Kconfig create mode 100644 drivers/misc/sprd-wcn/radio/Makefile create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv.h create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_main.c create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_main.h create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_ops.c create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_ops.h create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_rds_parser.c create mode 100644 drivers/misc/sprd-wcn/radio/fmdrv_rds_parser.h -- 2.7.4
Re: [PATCH 2/2] misc: added Spreadtrum's radio driver
On 4 July 2017 at 18:51, Arnd Bergmann wrote: > On Tue, Jul 4, 2017 at 12:15 PM, Chunyan Zhang > wrote: >> This patch added FM radio driver for Spreadtrum's SC2342, which's >> a WCN SoC, also added a new directory for Spreadtrum's WCN SoCs. >> >> Signed-off-by: Songhe Wei >> Signed-off-by: Chunyan Zhang > > (adding linux-media folks to Cc) (You forgot to add them in :)) > > Hi Chunyan, Hi Arnd, > > Thanks for posting this for inclusion as Greg asked for. I'm not sure what > the policy is for new radio drivers, but I assume this would have to go > to drivers/staging/media/ as it is a driver for hardware that fits into > drivers/media/radio but doesn't use the respective APIs. Ok, I agree to let it go to drivers/staging/media/. Like I mentioned, SC2342 includes many functions, this patch is only adding FM radio function included in SC2342 to the kernel tree. So I figure that its lifetime probably will not be too long, will remove it from the kernel tree when we have a clean enough version of the whole SC2342 drivers for the official upstreaming. Thanks, Chunyan > > Arnd > --- > end of message, full patch quoted for reference below >
[PATCH 2/3] mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c
This patch changes the 32-bit time type (timeval) to the 64-bit one (ktime_t), since 32-bit time types will break in the year 2038. I use ktime_t instead of timeval to define 'start' and 'finish' which are used to get the time for tow points. This patch also changes do_gettimeofday() to ktime_get() accordingly, since ktime_get returns a ktime_t, but do_gettimeofday returns a struct timeval, and the other reason is that ktime_get() uses the monotonic clock. This patch will use a new function 'ktime_ms_delta' which is introduced in 1/3 of this patch-set to get the millisecond time difference. Signed-off-by: Chunyan Zhang Reviewed-by: Arnd Bergmann --- drivers/mtd/tests/speedtest.c | 10 +- drivers/mtd/tests/torturetest.c | 10 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/tests/speedtest.c b/drivers/mtd/tests/speedtest.c index 5ee9f70..87a6e25 100644 --- a/drivers/mtd/tests/speedtest.c +++ b/drivers/mtd/tests/speedtest.c @@ -22,6 +22,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -49,7 +50,7 @@ static int pgsize; static int ebcnt; static int pgcnt; static int goodebcnt; -static struct timeval start, finish; +static ktime_t start, finish; static int multiblock_erase(int ebnum, int blocks) { @@ -168,12 +169,12 @@ static int read_eraseblock_by_2pages(int ebnum) static inline void start_timing(void) { - do_gettimeofday(&start); + start = ktime_get(); } static inline void stop_timing(void) { - do_gettimeofday(&finish); + finish = ktime_get(); } static long calc_speed(void) @@ -181,8 +182,7 @@ static long calc_speed(void) uint64_t k; long ms; - ms = (finish.tv_sec - start.tv_sec) * 1000 + -(finish.tv_usec - start.tv_usec) / 1000; + ms = ktime_ms_delta(finish, start); if (ms == 0) return 0; k = goodebcnt * (mtd->erasesize / 1024) * 1000; diff --git a/drivers/mtd/tests/torturetest.c b/drivers/mtd/tests/torturetest.c index eeab969..7e77ed4 100644 --- a/drivers/mtd/tests/torturetest.c +++ b/drivers/mtd/tests/torturetest.c @@ -26,6 +26,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -79,18 +80,18 @@ static unsigned char *check_buf; static unsigned int erase_cycles; static int pgsize; -static struct timeval start, finish; +static ktime_t start, finish; static void report_corrupt(unsigned char *read, unsigned char *written); static inline void start_timing(void) { - do_gettimeofday(&start); + start = ktime_get(); } static inline void stop_timing(void) { - do_gettimeofday(&finish); + finish = ktime_get(); } /* @@ -322,8 +323,7 @@ static int __init tort_init(void) long ms; stop_timing(); - ms = (finish.tv_sec - start.tv_sec) * 1000 + -(finish.tv_usec - start.tv_usec) / 1000; + ms = ktime_ms_delta(finish, start); pr_info("%08u erase cycles done, took %lu " "milliseconds (%lu seconds)\n", erase_cycles, ms, ms / 1000); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] ktime.h: Introduce ktime_ms_delta
This patch introduces a reusable time difference function which returns the difference in millisecond, as often used in some driver code, e.g. mtd/test, media/rc, etc. Signed-off-by: Chunyan Zhang Acked-by: Arnd Bergmann --- include/linux/ktime.h |5 + 1 file changed, 5 insertions(+) diff --git a/include/linux/ktime.h b/include/linux/ktime.h index c9d645a..891ea92 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h @@ -186,6 +186,11 @@ static inline s64 ktime_us_delta(const ktime_t later, const ktime_t earlier) return ktime_to_us(ktime_sub(later, earlier)); } +static inline s64 ktime_ms_delta(const ktime_t later, const ktime_t earlier) +{ + return ktime_to_ms(ktime_sub(later, earlier)); +} + static inline ktime_t ktime_add_us(const ktime_t kt, const u64 usec) { return ktime_add_ns(kt, usec * NSEC_PER_USEC); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] media: rc: Replace timeval with ktime_t in imon.c
This patch changes the 32-bit time type (timeval) to the 64-bit one (ktime_t), since 32-bit time types will break in the year 2038. I use ktime_t instead of all uses of timeval in imon.c This patch also changes do_gettimeofday() to ktime_get() accordingly, since ktime_get returns a ktime_t, but do_gettimeofday returns a struct timeval, and the other reason is that ktime_get() uses the monotonic clock. This patch will use a new function 'ktime_ms_delta' which is introduced in 1/3 of this patch-set to get the millisecond time difference. Signed-off-by: Chunyan Zhang Acked-by: Mauro Carvalho Chehab --- drivers/media/rc/imon.c | 49 +-- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index b8837dd..a1e91d5 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include #include -#include #include #define MOD_AUTHOR "Jarod Wilson " @@ -1158,29 +1158,6 @@ out: return retval; } -static inline int tv2int(const struct timeval *a, const struct timeval *b) -{ - int usecs = 0; - int sec = 0; - - if (b->tv_usec > a->tv_usec) { - usecs = 100; - sec--; - } - - usecs += a->tv_usec - b->tv_usec; - - sec += a->tv_sec - b->tv_sec; - sec *= 1000; - usecs /= 1000; - sec += usecs; - - if (sec < 0) - sec = 1000; - - return sec; -} - /** * The directional pad behaves a bit differently, depending on whether this is * one of the older ffdc devices or a newer device. Newer devices appear to @@ -1191,16 +1168,16 @@ static inline int tv2int(const struct timeval *a, const struct timeval *b) */ static int stabilize(int a, int b, u16 timeout, u16 threshold) { - struct timeval ct; - static struct timeval prev_time = {0, 0}; - static struct timeval hit_time = {0, 0}; + ktime_t ct; + static ktime_t prev_time; + static ktime_t hit_time; static int x, y, prev_result, hits; int result = 0; - int msec, msec_hit; + long msec, msec_hit; - do_gettimeofday(&ct); - msec = tv2int(&ct, &prev_time); - msec_hit = tv2int(&ct, &hit_time); + ct = ktime_get(); + msec = ktime_ms_delta(ct, prev_time); + msec_hit = ktime_ms_delta(ct, hit_time); if (msec > 100) { x = 0; @@ -1596,9 +1573,9 @@ static void imon_incoming_packet(struct imon_context *ictx, int i; u64 scancode; int press_type = 0; - int msec; - struct timeval t; - static struct timeval prev_time = { 0, 0 }; + long msec; + ktime_t t; + static ktime_t prev_time; u8 ktype; /* filter out junk data on the older 0xffdc imon devices */ @@ -1692,10 +1669,10 @@ static void imon_incoming_packet(struct imon_context *ictx, /* Only panel type events left to process now */ spin_lock_irqsave(&ictx->kc_lock, flags); - do_gettimeofday(&t); + t = ktime_get(); /* KEY_MUTE repeats from knob need to be suppressed */ if (ictx->kc == KEY_MUTE && ictx->kc == ictx->last_keycode) { - msec = tv2int(&t, &prev_time); + msec = ktime_ms_delta(t, prev_time); if (msec < ictx->idev->rep[REP_DELAY]) { spin_unlock_irqrestore(&ictx->kc_lock, flags); return; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] Changes the time type 'timeval' to 'Ktime'
This patch-set changes the 32-bit time type (timeval) to the 64-bit one (ktime_t) in imon.c, speedtest.c and torturetest.c, since 32-bit time types will break in the year 2038. This patch-set also introduces a reusable time difference function which returns the difference in millisecond in ktime.h. The last two patches of this patch-set will use this function, so they are dependent on the first one. Chunyan Zhang (3): ktime.h: Introduce ktime_ms_delta mtd: test: Replace timeval with ktime_t in speedtest.c and torturetest.c media: rc: Replace timeval with ktime_t in imon.c drivers/media/rc/imon.c | 49 +++ drivers/mtd/tests/speedtest.c | 10 drivers/mtd/tests/torturetest.c | 10 include/linux/ktime.h |5 4 files changed, 28 insertions(+), 46 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] media: rc: Replace timeval with ktime_t in imon.c
On Thu, Dec 18, 2014 at 7:00 PM, Mauro Carvalho Chehab wrote: > Em Thu, 18 Dec 2014 17:38:14 +0800 > Chunyan Zhang escreveu: > >> On Thu, Dec 18, 2014 at 3:50 PM, Arnd Bergmann wrote: >> > On Thursday 18 December 2014 11:37:13 Chunyan Zhang wrote: >> >> This patch changes the 32-bit time type (timeval) to the 64-bit one >> >> (ktime_t), since 32-bit time types will break in the year 2038. >> >> >> >> I use ktime_t instead of all uses of timeval in imon.c >> >> >> >> This patch also changes do_gettimeofday() to ktime_get() accordingly, >> >> since ktime_get returns a ktime_t, but do_gettimeofday returns a >> >> struct timeval, and the other reason is that ktime_get() uses >> >> the monotonic clock. >> >> >> >> This patch use a new function which is provided by another patch listed >> >> below >> >> to get the millisecond time difference. >> > >> > The patch looks great. Just a few small details that could still be >> > improved: > > Yes, patch looks OK. After addressing the bits pointed by Arnd: > > Acked-by: Mauro Carvalho Chehab > > Feel free to merge via y2038 tree. > Ok, thank you, I'll send the updated patch-set soon. Chunyan -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] media: rc: Replace timeval with ktime_t in imon.c
On Thu, Dec 18, 2014 at 3:50 PM, Arnd Bergmann wrote: > On Thursday 18 December 2014 11:37:13 Chunyan Zhang wrote: >> This patch changes the 32-bit time type (timeval) to the 64-bit one >> (ktime_t), since 32-bit time types will break in the year 2038. >> >> I use ktime_t instead of all uses of timeval in imon.c >> >> This patch also changes do_gettimeofday() to ktime_get() accordingly, >> since ktime_get returns a ktime_t, but do_gettimeofday returns a >> struct timeval, and the other reason is that ktime_get() uses >> the monotonic clock. >> >> This patch use a new function which is provided by another patch listed below >> to get the millisecond time difference. > > The patch looks great. Just a few small details that could still be > improved: > >> http://lkml.iu.edu//hypermail/linux/kernel/1412.2/00625.html >> >> Signed-off-by: Chunyan Zhang > > In general, when you give a mailing list link, use the 'Link' tag > under your Signed-off-by line, like > > Link: http://lkml.iu.edu//hypermail/linux/kernel/1412.2/00625.html > > It's not used much yet, but getting more popular and seems useful to me. > > In this particular case, when you have patches that depend on one > another, you can make do it even better by sending all three patches > as a series with a [PATCH 0/3] cover letter. > OK, I'll send a patch-set including these three patches > If the media maintainers can provide an Ack for this patch, I would > suggest to queue it up in the y2038 branch together with your first > patch that it depends on. > >> @@ -1191,16 +1168,16 @@ static inline int tv2int(const struct timeval *a, >> const struct timeval *b) >> */ >> static int stabilize(int a, int b, u16 timeout, u16 threshold) >> { >> - struct timeval ct; >> - static struct timeval prev_time = {0, 0}; >> - static struct timeval hit_time = {0, 0}; >> + ktime_t ct; >> + static ktime_t prev_time = {0}; >> + static ktime_t hit_time = {0}; >> static int x, y, prev_result, hits; >> int result = 0; > > The "= {0}" part here is redundant, since static variables are always > initialized to zero. Normally, adding the explicit initializer can > help readability, but in this case I would leave it out because it shows > implementation details of ktime_t that are better hidden from drivers. > OK, I'll modify them soon Thanks, Chunyan >> @@ -1596,9 +1573,9 @@ static void imon_incoming_packet(struct imon_context >> *ictx, >> int i; >> u64 scancode; >> int press_type = 0; >> - int msec; >> - struct timeval t; >> - static struct timeval prev_time = { 0, 0 }; >> + long msec; >> + ktime_t t; >> + static ktime_t prev_time = {0}; >> u8 ktype; > > Same thing here of course. > > Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] media: rc: Replace timeval with ktime_t in imon.c
This patch changes the 32-bit time type (timeval) to the 64-bit one (ktime_t), since 32-bit time types will break in the year 2038. I use ktime_t instead of all uses of timeval in imon.c This patch also changes do_gettimeofday() to ktime_get() accordingly, since ktime_get returns a ktime_t, but do_gettimeofday returns a struct timeval, and the other reason is that ktime_get() uses the monotonic clock. This patch use a new function which is provided by another patch listed below to get the millisecond time difference. http://lkml.iu.edu//hypermail/linux/kernel/1412.2/00625.html Signed-off-by: Chunyan Zhang --- drivers/media/rc/imon.c | 49 +-- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index b8837dd..a641139 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include #include -#include #include #define MOD_AUTHOR "Jarod Wilson " @@ -1158,29 +1158,6 @@ out: return retval; } -static inline int tv2int(const struct timeval *a, const struct timeval *b) -{ - int usecs = 0; - int sec = 0; - - if (b->tv_usec > a->tv_usec) { - usecs = 100; - sec--; - } - - usecs += a->tv_usec - b->tv_usec; - - sec += a->tv_sec - b->tv_sec; - sec *= 1000; - usecs /= 1000; - sec += usecs; - - if (sec < 0) - sec = 1000; - - return sec; -} - /** * The directional pad behaves a bit differently, depending on whether this is * one of the older ffdc devices or a newer device. Newer devices appear to @@ -1191,16 +1168,16 @@ static inline int tv2int(const struct timeval *a, const struct timeval *b) */ static int stabilize(int a, int b, u16 timeout, u16 threshold) { - struct timeval ct; - static struct timeval prev_time = {0, 0}; - static struct timeval hit_time = {0, 0}; + ktime_t ct; + static ktime_t prev_time = {0}; + static ktime_t hit_time = {0}; static int x, y, prev_result, hits; int result = 0; - int msec, msec_hit; + long msec, msec_hit; - do_gettimeofday(&ct); - msec = tv2int(&ct, &prev_time); - msec_hit = tv2int(&ct, &hit_time); + ct = ktime_get(); + msec = ktime_ms_delta(ct, prev_time); + msec_hit = ktime_ms_delta(ct, hit_time); if (msec > 100) { x = 0; @@ -1596,9 +1573,9 @@ static void imon_incoming_packet(struct imon_context *ictx, int i; u64 scancode; int press_type = 0; - int msec; - struct timeval t; - static struct timeval prev_time = { 0, 0 }; + long msec; + ktime_t t; + static ktime_t prev_time = {0}; u8 ktype; /* filter out junk data on the older 0xffdc imon devices */ @@ -1692,10 +1669,10 @@ static void imon_incoming_packet(struct imon_context *ictx, /* Only panel type events left to process now */ spin_lock_irqsave(&ictx->kc_lock, flags); - do_gettimeofday(&t); + t = ktime_get(); /* KEY_MUTE repeats from knob need to be suppressed */ if (ictx->kc == KEY_MUTE && ictx->kc == ictx->last_keycode) { - msec = tv2int(&t, &prev_time); + msec = ktime_ms_delta(t, prev_time); if (msec < ictx->idev->rep[REP_DELAY]) { spin_unlock_irqrestore(&ictx->kc_lock, flags); return; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html