summaryrefslogtreecommitdiff
path: root/drivers/media/pci/cx88/cx88-dsp.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-11-20 00:27:30 +0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-11-25 12:50:20 +0300
commit399426cadf5b0539a5b2a4d805257ce8acc6aba2 (patch)
tree40dec68657fbd2904ec6da9c2082fd29d0f3b437 /drivers/media/pci/cx88/cx88-dsp.c
parent1d38971438157dc57f0a4be89abf23b472458633 (diff)
downloadlinux-399426cadf5b0539a5b2a4d805257ce8acc6aba2.tar.xz
[media] cx88: make checkpatch.pl happy
Usually, I don't like fixing coding style issues on non-staging drivers, as it could be a mess pretty easy, and could become like a snow ball. That's the case of recent changes on two changesets: they disalign some statements. Yet, a care a lot with cx88 driver, as it was the first driver I touched at the Kernel, and I've been maintaining it since 2005. So, several of the coding style issues were due to my code. Per Andrey's suggestion, I ran checkpatch.pl in strict mode, with fixed several other issues, did some function alinments, but broke other alinments. So, I had to manually apply another round of manual fixes to make sure that everything is ok, and to make checkpatch happy with this patch. With this patch, checkpatch.pl is now happy when called with: ./scripts/checkpatch.pl -f --max-line-length=998 --ignore PREFER_PR_LEVEL Also, the 80-cols violations that made sense were fixed. Checkpatch would be happier if we convert it to use dev_foo(), but this is a more complex change. NOTE: there are some places with msleep(1). As this driver was written at the time that the default was to sleep at least 10ms on such calls (e. g. CONFIG_HZ=100), I replaced those calls by usleep_range(10000, 20000), with should be safe to avoid breakages. Fixes: 65bc2fe86e66 ("[media] cx88: convert it to use pr_foo() macros") Fixes: 7b61ba8ff838 ("[media] cx88: make checkpatch happier") Suggested-by: Andrey Utkin <andrey_utkin@fastmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Reviewed-by: Andrey Utkin <andrey_utkin@fastmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/pci/cx88/cx88-dsp.c')
-rw-r--r--drivers/media/pci/cx88/cx88-dsp.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/drivers/media/pci/cx88/cx88-dsp.c b/drivers/media/pci/cx88/cx88-dsp.c
index 235124e2a763..105029088120 100644
--- a/drivers/media/pci/cx88/cx88-dsp.c
+++ b/drivers/media/pci/cx88/cx88-dsp.c
@@ -31,18 +31,22 @@
#define baseband_freq(carrier, srate, tone) ((s32)( \
(compat_remainder(carrier + tone, srate)) / srate * 2 * INT_PI))
-/* We calculate the baseband frequencies of the carrier and the pilot tones
- * based on the the sampling rate of the audio rds fifo. */
+/*
+ * We calculate the baseband frequencies of the carrier and the pilot tones
+ * based on the the sampling rate of the audio rds fifo.
+ */
#define FREQ_A2_CARRIER baseband_freq(54687.5, 2689.36, 0.0)
#define FREQ_A2_DUAL baseband_freq(54687.5, 2689.36, 274.1)
#define FREQ_A2_STEREO baseband_freq(54687.5, 2689.36, 117.5)
-/* The frequencies below are from the reference driver. They probably need
+/*
+ * The frequencies below are from the reference driver. They probably need
* further adjustments, because they are not tested at all. You may even need
* to play a bit with the registers of the chip to select the proper signal
* for the input of the audio rds fifo, and measure it's sampling rate to
- * calculate the proper baseband frequencies... */
+ * calculate the proper baseband frequencies...
+ */
#define FREQ_A2M_CARRIER ((s32)(2.114516 * 32768.0))
#define FREQ_A2M_DUAL ((s32)(2.754916 * 32768.0))
@@ -83,8 +87,10 @@ static s32 int_cos(u32 x)
x = x % INT_PI;
if (x > INT_PI / 2)
return -int_cos(INT_PI / 2 - (x % (INT_PI / 2)));
- /* Now x is between 0 and INT_PI/2.
- * To calculate cos(x) we use it's Taylor polinom. */
+ /*
+ * Now x is between 0 and INT_PI/2.
+ * To calculate cos(x) we use it's Taylor polinom.
+ */
t2 = x * x / 32768 / 2;
t4 = t2 * x / 32768 * x / 32768 / 3 / 4;
t6 = t4 * x / 32768 * x / 32768 / 5 / 6;
@@ -95,8 +101,10 @@ static s32 int_cos(u32 x)
static u32 int_goertzel(s16 x[], u32 N, u32 freq)
{
- /* We use the Goertzel algorithm to determine the power of the
- * given frequency in the signal */
+ /*
+ * We use the Goertzel algorithm to determine the power of the
+ * given frequency in the signal
+ */
s32 s_prev = 0;
s32 s_prev2 = 0;
s32 coeff = 2 * int_cos(freq);
@@ -115,12 +123,14 @@ static u32 int_goertzel(s16 x[], u32 N, u32 freq)
tmp = (s64)s_prev2 * s_prev2 + (s64)s_prev * s_prev -
(s64)coeff * s_prev2 * s_prev / 32768;
- /* XXX: N must be low enough so that N*N fits in s32.
- * Else we need two divisions. */
+ /*
+ * XXX: N must be low enough so that N*N fits in s32.
+ * Else we need two divisions.
+ */
divisor = N * N;
do_div(tmp, divisor);
- return (u32) tmp;
+ return (u32)tmp;
}
static u32 freq_magnitude(s16 x[], u32 N, u32 freq)
@@ -187,7 +197,8 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 x[], u32 N)
dual = freq_magnitude(x, N, dual_freq);
noise = noise_magnitude(x, N, FREQ_NOISE_START, FREQ_NOISE_END);
- dprintk(1, "detect a2/a2m/eiaj: carrier=%d, stereo=%d, dual=%d, noise=%d\n",
+ dprintk(1,
+ "detect a2/a2m/eiaj: carrier=%d, stereo=%d, dual=%d, noise=%d\n",
carrier, stereo, dual, noise);
if (stereo > dual)
@@ -201,8 +212,10 @@ static s32 detect_a2_a2m_eiaj(struct cx88_core *core, s16 x[], u32 N)
(carrier < max(stereo, dual) * 6) &&
(carrier > 20 && carrier < 200) &&
(max(stereo, dual) > min(stereo, dual))) {
- /* For EIAJ the carrier is always present,
- so we probably don't need noise detection */
+ /*
+ * For EIAJ the carrier is always present,
+ * so we probably don't need noise detection
+ */
return ret;
}
} else {
@@ -243,7 +256,8 @@ static s16 *read_rds_samples(struct cx88_core *core, u32 *N)
u32 current_address = cx_read(srch->ptr1_reg);
u32 offset = (current_address - srch->fifo_start + bpl);
- dprintk(1, "read RDS samples: current_address=%08x (offset=%08x), sample_count=%d, aud_intstat=%08x\n",
+ dprintk(1,
+ "read RDS samples: current_address=%08x (offset=%08x), sample_count=%d, aud_intstat=%08x\n",
current_address,
current_address - srch->fifo_start, sample_count,
cx_read(MO_AUD_INTSTAT));
@@ -308,9 +322,9 @@ s32 cx88_dsp_detect_stereo_sap(struct cx88_core *core)
if (ret != UNSET)
dprintk(1, "stereo/sap detection result:%s%s%s\n",
- (ret & V4L2_TUNER_SUB_MONO) ? " mono" : "",
- (ret & V4L2_TUNER_SUB_STEREO) ? " stereo" : "",
- (ret & V4L2_TUNER_SUB_LANG2) ? " dual" : "");
+ (ret & V4L2_TUNER_SUB_MONO) ? " mono" : "",
+ (ret & V4L2_TUNER_SUB_STEREO) ? " stereo" : "",
+ (ret & V4L2_TUNER_SUB_LANG2) ? " dual" : "");
return ret;
}