Commit graph

1021 commits

Author SHA1 Message Date
Nikita Yushchenko f8a9a29c4f
ASoC: rsnd: set pm_ops in hibernate-compatible way
Use SET_SYSTEM_SLEEP_PM_OPS() macro instead of direct assignment to
.suspend and .resume fields.

This makes driver working after restore from hibernation.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-03-21 09:29:52 +08:00
Kuninori Morimoto 1f6e920faa
ASoC: rsnd: suppress rsnd_dai_call() debug message
rsnd_dai_call() is using dev_dbg(), but its message is sometimes
blocks nessesary other messages. If RSND_DEBUG_NO_DAI_CALL was
defined it will be suppressed by this patch.

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-02-13 11:58:26 +00:00
Kuninori Morimoto 2b62786951
ASoC: rsnd: indicate IRQ error status for debug
SSI/SRC have under/over flow error handling, and its status is useful
for debuging. But sometimes it might be too much message,
and it might blocks necessity other information.

To avoid such situation, basically this patch indicates interrupt
status debug message if DEBUG was defined, but it will be suppressed
if RSND_DEBUG_NO_IRQ_STATUS was defined.

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-02-13 11:58:22 +00:00
Kuninori Morimoto be3eabe998
ASoC: sh: siu: replace platform to component
Now platform can be replaced to component, let's do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-02-12 11:45:15 +00:00
Kuninori Morimoto f5a82fa601
ASoC: sh: fsi: replace platform to component
Now platform can be replaced to component, let's do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-02-12 11:45:15 +00:00
Kuninori Morimoto eb5d510c86
ASoC: sh: dma-sh7760: replace platform to component
Now platform can be replaced to component, let's do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-02-12 11:45:14 +00:00
Kuninori Morimoto 019ea01b7c
ASoC: sh: rsnd: replace platform to component
Now platform can be replaced to component, let's do it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2018-02-12 11:45:13 +00:00
Mark Brown 7c29e706b6
Merge remote-tracking branch 'asoc/topic/rcar' into asoc-next 2018-01-05 12:43:33 +00:00
Kuninori Morimoto d5aa24825d
ASoC: rsnd: fixup ADG register mask
BRGCKR should use 0x80770000, instead of 0x80FF0000.

R-Car Gen2 xxx_TIMSEL should use 0x0F1F,
R-Car Gen3 xxx_TIMSEL should use 0x1F1F.
Here, Gen3 doesn't support AVD, thus, both case can use 0x0F1F.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-20 10:49:06 +00:00
Kuninori Morimoto 9f76118394
ASoC: rsnd: remove unneeded "is_graph" from __rsnd_dai_probe()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-11 12:05:04 +00:00
Kuninori Morimoto d8d9b9730c
ASoC: rsnd: PIO related function cleanup
SSI had shared counting pointer position method between PIO/DMA mode
before. But now DMA mode is using DMAEngine feature to get it.
Thus, this counting pointer position method is needed for only PIO mode.
We don't need to share code anymore.
This patch names PIO related functions as rsnd_ssi_pio_xxx(), and
merged/cleanuped each feature.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-11 12:05:03 +00:00
Kuninori Morimoto 41acc8ec04
ASoC: rsnd: don't use runtime->sample_bits
Current rsnd driver is judging 16bit/24bit data by using
runtime->sample_bits, but it is indicating physical size,
not format size. This is confusable code.
This patch uses snd_pcm_format_width() to be more correct code.

Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-11 12:05:02 +00:00
Kuninori Morimoto a914e44693
ASoC: rsnd: more clear rsnd_get_dalign() for DALIGN
On Renesas sound device, DALIGN which exchanges channel position
is needed because SW and HW are using defferent data order if
16bit data. It is not needed when 24bit data.
rsnd_get_dalign() returns necessary value, but it was confusable
code. This patch makes it more simple.

Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-08 18:53:51 +00:00
Jiada Wang 2e2d53da81
ASoC: rsnd: ssi: remove unnesessary period_pos
period_pos can always be calculated by byte_pos and
byte_per_period, there is no reason to maintain this
variable in rsnd_dai_stream.

This patch removes period_pos from rsnd_ssi and calculates
next_period_byte with consideration of actual byte_pos value.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-08 18:53:32 +00:00
Mark Brown c046010a83
Merge branch 'fix/rcar' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-rcar 2017-12-08 18:53:18 +00:00
Jiada Wang 33f801366b
ASoC: rsnd: ssi: fix race condition in rsnd_ssi_pointer_update
Currently there is race condition between set of byte_pos and wrap
it around when new buffer starts. If .pointer is called in-between
it will result in inconsistent pointer position be returned
from .pointer callback.

This patch increments buffer pointer atomically to avoid this issue.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Reviewed-by: Takashi Sakamoto <takashi.sakamoto@miraclelinux.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-12-08 18:51:32 +00:00
Kuninori Morimoto 65bedda1fe
ASoC: rsnd: dma.c: spin lock is no longer needed in IRQ handler
DMA handler had needed to calculate pointer before, but it doesn't
need now. Thus, we can remove unnecessary spin lock from DMAC handler.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-29 10:16:48 +00:00
Kuninori Morimoto b2fb31bb74
ASoC: rsnd: TDM 6ch needs 8ch clock for hw refine
Renesas sound needs 8ch clock if TDM 6ch mode, and needs 2ch clock for
6ch or 8ch sound if Multi SSI mode. And these are related to before/after
CTU (= Channel Transfer Unit).
To calculate these we already has rsnd_runtime_channel_for_ssi() which
returns runtime necessary channels.
But, it based on runtime->channels  which is not yet set when hw refine.
We need to use hw_params instead of runtime->xxx when hw refine,
and it is not needed after runtime was set.
This patch adds new hw_params on rsnd_dai_stream, and it will be removed
on rsnd_hw_params().
This is very temporary durty code, but it seems no choice at this point.

Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-29 10:16:03 +00:00
Kuninori Morimoto 180d9ef581
ASoC: rsnd: call snd_soc_disconnect_sync() when remove
Renesas R-Car sound driver should be stopped if unbinded during
playbacking/capturing. Otherwise clock open/close counter mismatch
happen.

One note is that we can't skip from remove function (= return -Exxx)
in such case if user used unbind. Because unbind function doesn't
check return value from each driver's remove function.
This means we must to stop and remove driver in remove function.

Now ASoC has snd_soc_disconnect_sync() for this purpose.
Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-28 16:20:49 +00:00
Jiada Wang a91d7fb970
ASoC: rsnd: ssiu: clear SSI_MODE for non TDM Extended modes
register SSI_MODE is set when SSI works in TDM Extended,
but it isn't reset when SSI starts to work in other modes,
thus causes issues.

This patch clearss SSI_MODE register when SSI works in modes
other than TDM Extended.

Fixes: 186fadc132 ("ASoC: rsnd: add TDM Extend Mode support")
Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-28 11:52:52 +00:00
Kuninori Morimoto c20c6704bf
ASoC: rcar: revert IOMMU support so far
commit 4821d914fe ("ASoC: rsnd: use dma_sync_single_for_xxx() for
IOMMU") had supported IOMMU, but it breaks normal sound "recorde"
and both PulseAudio's "playback/recorde". The sound will be noisy.

That commit was using dma_sync_single_for_xxx(), and driver should
make sure memory is protected during CPU or Device are using it.
But if driver returns current "residue" data size correctly on pointer
function, player/recorder will access to protected memory.

IOMMU feature should be supported, but I don't know how to handle it
without memory cache problem at this point.
Thus, this patch simply revert it to avoid current noisy sound.

Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Tested-by: Ryo Kodama <ryo.kodama.vz@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-16 11:02:04 +00:00
Mark Brown 033d56f6c0
Merge remote-tracking branches 'asoc/topic/dwc', 'asoc/topic/fallthrough', 'asoc/topic/fsi', 'asoc/topic/fsl' and 'asoc/topic/graph' into asoc-next 2017-11-10 21:31:13 +00:00
Mark Brown f904f84609
Merge remote-tracking branch 'asoc/topic/rcar' into asoc-next 2017-11-10 21:30:57 +00:00
Mark Brown 16a077e17c ASoC: Fixes for v4.14
I've been quite lax in sending these due to conference season but here's
 a fairly large collection of ASoC updates.  The one thing that's not
 device specific is Takashi's fix for races between delayed work and PCM
 destruction, otherwise everything is specific to an individual device.
 -----BEGIN PGP SIGNATURE-----
 
 iQFHBAABCgAxFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlnx7QsTHGJyb29uaWVA
 a2VybmVsLm9yZwAKCRAk1otyXVSH0H6gB/9Kg6nfaNQDH3ScDO/0KXJevvc9DZUG
 1Mgb6o866WQKVKwHL4/7PeUnwpaAh/Dr5KN7bFS7nImrZlHiJfv64Cmrrca+VMwa
 O9SnAxbzMDN1MXV3uLDlmd5jJ2EETGnSSo31gjyOuFAmvWRYhtvN4QtoLRBQYYJ9
 A32JAKYXKpdjYlIq8sssf1Ey9OcReho3klAc578Yw5qsuHTsB8yJ5SNy0YgmobCm
 rNs+LcY9fBPQxY1nVW5iJ3L8oR9RXlUOdZy1I220i0q6+ku1nynbh64V8m7fFGmp
 KQLIVvH8JGlqaGBidU47C3vwEnUN88y0+98i9dF4Hc26E+Ml3YNyL/z6
 =TVgt
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQFHBAABCgAxFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAloGGn8THGJyb29uaWVA
 a2VybmVsLm9yZwAKCRAk1otyXVSH0BAsB/9tbgkbKpUVsWEQOTXDtz1VARb5+zxJ
 zMRmYGdcfV+au4pmo07NwcxwFDqeLxmsd7dRM+eoPJGbxklD9rr9eL9tZiO1TI0B
 jla9eyKO1aRjCD8dEDsQJEUjDGWWbrpYRvFjlTmYW5cf1vgE9Ta7QtwBN+mK+Ssn
 1PtwfHg5lDffoCMGOgu/5Kah4QhzAIU1mM4Vg77VgsuScZEw5qMYJUncfkdsH6M5
 JiQJpOQR/wNL4/IETodjhFzqhi9vlUvDEfmATNMpHMdHA//erUbphUt2bAjqVauM
 zKTFTSN1vvW1GirJyxz4NiHXQ6upbpZPMDcPsfOzJhHw82OAwx/pp1QT
 =bBtM
 -----END PGP SIGNATURE-----

Merge tag 'asoc-fix-v4.14-rc6' into asoc-linus

ASoC: Fixes for v4.14

I've been quite lax in sending these due to conference season but here's
a fairly large collection of ASoC updates.  The one thing that's not
device specific is Takashi's fix for races between delayed work and PCM
destruction, otherwise everything is specific to an individual device.

# gpg: Signature made Thu 26 Oct 2017 15:11:23 BST
# gpg:                using RSA key ADE668AA675718B59FE29FEA24D68B725D5487D0
# gpg:                issuer "broonie@kernel.org"
# gpg: Good signature from "Mark Brown <broonie@sirena.org.uk>" [unknown]
# gpg:                 aka "Mark Brown <broonie@debian.org>" [unknown]
# gpg:                 aka "Mark Brown <broonie@kernel.org>" [unknown]
# gpg:                 aka "Mark Brown <broonie@tardis.ed.ac.uk>" [unknown]
# gpg:                 aka "Mark Brown <broonie@linaro.org>" [unknown]
# gpg:                 aka "Mark Brown <Mark.Brown@linaro.org>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 3F25 68AA C269 98F9 E813  A1C5 C3F4 36CA 30F5 D8EB
#      Subkey fingerprint: ADE6 68AA 6757 18B5 9FE2  9FEA 24D6 8B72 5D54 87D0
2017-11-10 21:30:27 +00:00
Kuninori Morimoto c409c2a963
ASoC: rsnd: return -EIO if rsnd_dmaen_request_channel() failed
PTR_ERR(NULL) is success. Normally when a function returns both NULL
and error pointers, it means that NULL is not a error.
But, rsnd_dmaen_request_channel() returns NULL if requested resource
was failed.
Let's return -EIO if rsnd_dmaen_request_channel() was failed on
rsnd_dmaen_nolock_start().
This patch fixes commit edce5c496c ("ASoC: rsnd: Request/Release DMA
channel eachtime")

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-06 11:29:44 +00:00
Greg Kroah-Hartman b24413180f License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier.  The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.

This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.

How this work was done:

Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
 - file had no licensing information it it.
 - file was a */uapi/* one with no licensing information in it,
 - file was a */uapi/* one with existing licensing information,

Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.

The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne.  Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.

The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed.  Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.

Criteria used to select files for SPDX license identifier tagging was:
 - Files considered eligible had to be source code files.
 - Make and config files were included as candidates if they contained >5
   lines of source
 - File already had some variant of a license header in it (even if <5
   lines).

All documentation files were explicitly excluded.

The following heuristics were used to determine which SPDX license
identifiers to apply.

 - when both scanners couldn't find any license traces, file was
   considered to have no license information in it, and the top level
   COPYING file license applied.

   For non */uapi/* files that summary was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0                                              11139

   and resulted in the first patch in this series.

   If that file was a */uapi/* path one, it was "GPL-2.0 WITH
   Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:

   SPDX license identifier                            # files
   ---------------------------------------------------|-------
   GPL-2.0 WITH Linux-syscall-note                        930

   and resulted in the second patch in this series.

 - if a file had some form of licensing information in it, and was one
   of the */uapi/* ones, it was denoted with the Linux-syscall-note if
   any GPL family license was found in the file or had no licensing in
   it (per prior point).  Results summary:

   SPDX license identifier                            # files
   ---------------------------------------------------|------
   GPL-2.0 WITH Linux-syscall-note                       270
   GPL-2.0+ WITH Linux-syscall-note                      169
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
   ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
   LGPL-2.1+ WITH Linux-syscall-note                      15
   GPL-1.0+ WITH Linux-syscall-note                       14
   ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
   LGPL-2.0+ WITH Linux-syscall-note                       4
   LGPL-2.1 WITH Linux-syscall-note                        3
   ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
   ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1

   and that resulted in the third patch in this series.

 - when the two scanners agreed on the detected license(s), that became
   the concluded license(s).

 - when there was disagreement between the two scanners (one detected a
   license but the other didn't, or they both detected different
   licenses) a manual inspection of the file occurred.

 - In most cases a manual inspection of the information in the file
   resulted in a clear resolution of the license that should apply (and
   which scanner probably needed to revisit its heuristics).

 - When it was not immediately clear, the license identifier was
   confirmed with lawyers working with the Linux Foundation.

 - If there was any question as to the appropriate license identifier,
   the file was flagged for further research and to be revisited later
   in time.

In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.

Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights.  The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.

Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.

In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.

Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
 - a full scancode scan run, collecting the matched texts, detected
   license ids and scores
 - reviewing anything where there was a license detected (about 500+
   files) to ensure that the applied SPDX license was correct
 - reviewing anything where there was no detection but the patch license
   was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
   SPDX license was correct

This produced a worksheet with 20 files needing minor correction.  This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.

These .csv files were then reviewed by Greg.  Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected.  This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.)  Finally Greg ran the script using the .csv files to
generate the patches.

Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02 11:10:55 +01:00
Kuninori Morimoto 9b6ea25066
ASoC: rsnd: remove NULL check from rsnd_mod_name()/rsnd_mod_id()
Current rsnd driver has rsnd_mod_id() which returns mod ID,
and it returns -1 if mod was NULL.
In the same time, this driver has rsnd_mod_name() which returns mod
name, and it returns "unknown" if mod or mod->ops was NULL.

Basically these "mod" never be NULL, but the reason why rsnd driver
has such behavior is that DMA path finder is assuming memory as
"mod == NULL".
Thus, current DMA path debug code prints like below.
Here "unknown[-1]" means it was memory.

	...
	rcar_sound ec500000.sound:   unknown[-1] from
	rcar_sound ec500000.sound:   src[0] to
	rcar_sound ec500000.sound:   ctu[2]
	rcar_sound ec500000.sound:   mix[0]
	rcar_sound ec500000.sound:   dvc[0]
	rcar_sound ec500000.sound:   ssi[0]
	rcar_sound ec500000.sound: audmac[0] unknown[-1] -> src[0]
	...

1st issue is that it is confusable for user.
2nd issue is rsnd driver has something like below code.

	mask |= 1 << rsnd_mod_id(mod);

Because of this kind of code, some statically code checker will
reports "Shifting by a negative value is undefined behaviour".

But this "mod" never be NULL, thus negative shift never happen.
To avoid these issues, this patch adds new dummy "mem" to
indicate memory, and use it to indicate debug information,
and, remove unneeded "NULL mod" behavior from rsnd_mod_id() and
rsnd_mod_name().

The debug information will be like below by this patch
	...
	rcar_sound ec500000.sound:   mem[0] from
	rcar_sound ec500000.sound:   src[0] to
	rcar_sound ec500000.sound:   ctu[2]
	rcar_sound ec500000.sound:   mix[0]
	rcar_sound ec500000.sound:   dvc[0]
	rcar_sound ec500000.sound:   ssi[0]
	rcar_sound ec500000.sound: audmac[0] mem[0] -> src[0]
	...

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-01 09:53:19 +00:00
Kuninori Morimoto 21781e8788
ASoC: rsnd: rsnd_ssi_run_mods() needs to care ssi_parent_mod
SSI parent mod might be NULL. ssi_parent_mod() needs to care
about it. Otherwise, it uses negative shift.
This patch fixes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-11-01 09:53:01 +00:00
Kuninori Morimoto ce54893120
ASoC: rsnd: Don't check SSISR::DIRQ when Capture
When stop case, it was Playback, it need to check all data were
completely sent. But in Capture case, it might not receive data
anymore. SSISR::DIRQ check is not need for Capture case.

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-31 11:06:52 +00:00
Kuninori Morimoto 8fce974bc4
ASoC: rsnd: use snd_pcm_running() in rsnd_io_is_working()
Let's use more common style to checking running/working

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-31 11:06:49 +00:00
Kuninori Morimoto ed3ac14ca9
ASoC: rsnd: NULL check is not needed for clk_unprepare()
clk_unprepare() is checking parameter by IS_ERR_OR_NULL().
clk NULL check is not needed on rsnd_mod_quit()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-31 11:06:42 +00:00
Kuninori Morimoto b12f1e3a79
ASoC: rsnd: tidyup rsnd_mod_next() for loop method
Let's remove point less "continue"

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-31 11:06:35 +00:00
Kuninori Morimoto 138f878647
ASoC: rsnd: don't use io->mod[] directly
We have rsnd_io_to_mod() macro. Let's use it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-31 11:06:30 +00:00
Kuninori Morimoto 6cba3fa98c ASoC: rsnd: more clear ADG clock debug info
ADG inputs clock from CLK{A,B,C,I} and outputs clock from
CLKOUT{0,1,2,3} which is selected by BRG{A,B}.
Now, ADG is assuming BRGA is for 44100Hz related clocks,
BRGB is for 48000Hz related clocks.

Clock related debug is very difficult/confusable.
This patch cleanups clock related debug info.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-13 11:19:01 +01:00
Kuninori Morimoto 3a9fa27be5 ASoC: rsnd: add rsnd_kctrl_xxx() macro
Current CTU/MIX/DVC are directly using rsnd_kctrl_cfg_m/s to control
val etc, but it is difficult to read/understand.
And there was no uniformity in access method.
This patch adds new rsnd_kctrl_xxx() and implements uniformed access
method.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-11 09:46:17 +01:00
Geert Uytterhoeven b48cc1d9c3 ASoC: fsi: Use of_device_get_match_data() helper
Use the of_device_get_match_data() helper instead of open coding.
Note that when used with DT, there's always a valid match.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-04 15:48:05 +01:00
Kuninori Morimoto 3e3c9ee1e4 ASoC: rsnd: add MIX Volume Ramp support
Both DVC/MIX have Volume Ramp Control. This patch supprts MIX
Volume Ramp. One note is that main purpose of MIX Volume Ramp
is to reduce noise, thus, MIX Ramp range is very few if you
compare to DVC Volume Ramp (DVC = 5bit, MIX = 4bit).

You can use MIX Volume Ranp like below
	amixer set "MIX Ramp Up Rate"   "0.125 dB/1 step"
	amixer set "MIX Ramp Down Rate" "0.125 dB/1 step"
	amixer set "MIX Ramp" on
	aplay xxx.wav &
	amixer set "MIX",0  80%  // DAI0 Volume Down
	amixer set "MIX",1 100%  // DAI1 Volume Up

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-04 11:50:41 +01:00
Kuninori Morimoto f3c26ac61c ASoC: rsnd: makes volume ramp rate list generic
DVC is supporting Volume Ramp Rate, and MIX has Volume Ramp
but not yet supported. To support MIX Volume Ramp, we want to
share Rate List since DVC/MIX are using almost same list.
This patch move DVC specific Volume Ramp Rate List to core.c.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-04 11:50:38 +01:00
Kuninori Morimoto 99dc79d060 ASoC: rsnd: CTU kctrl sets once
Same CTU might be used few times if system/platform is using MIX.
For example below case.

	DAI0 playback = <&src0 &ctu02 &mix0 &dvc0 &ssi0>;
	DAI1 playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>;

This case, ALSA will have CTU,0 and CTU,1 kcontrol interfaces,
but these are same CTU. This is confusing.
This patch adds new flags and avoid such case.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-04 11:50:32 +01:00
Kuninori Morimoto b918f1bc7f ASoC: rsnd: DVC kctrl sets once
Same DVC might be used few times if system/platform is using MIX.
For example below case.

	DAI0 playback = <&src0 &ctu02 &mix0 &dvc0 &ssi0>;
	DAI1 playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>;

This case, ALSA will have DVC,0 and DVC,1 kcontrol interfaces,
but these are same DVC. This is confusing.
This patch adds new flags and avoid such case.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-04 11:50:29 +01:00
Kuninori Morimoto d0cf7fc948 ASoC: rsnd: use generic rsnd_flags_xxx() macro on ADG
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-04 11:50:24 +01:00
Kuninori Morimoto 429919890e ASoC: rsnd: add generic rsnd_flags_xxx() macro
SSI is using rsnd_ssi_flags_xxx() macro to control flags.
But it is useful macro not only for SSI. This patch replace it
to more generic rsnd_flags_xxx().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-04 11:50:19 +01:00
Kuninori Morimoto 9e9e95df06 ASoC: rcar: skip disabled-SSI nodes
The current device tree representation of the R-Car SSI assumes that they
are numbered consecutively, starting from 0. Alas, this is not the case
with the R8A77995 (D3) SoC which SSI1/SSI2 aren't present. In order to
keep the existing device trees working, I'm suggesting to use a disabled
node for SSI0/SSI1. Teach the SSI probe to just skip disabled nodes.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-10-03 09:51:40 -07:00
Kuninori Morimoto 81cb71240e ASoC: rsnd: add rsnd_dma_alloc()
R-Car sound DMA will be used from SSI/SRC.
dma.c doesn't alloc DMA handler in .probe timing, because we don't
know what kind of DMA transfer will be used then.
Thus, SSI/SRC have *rsnd_mod for DMA. rsnd_dma_attach() will allocate
it and attach it to system.
It will be PIO mode if it can't alloc DMA handler.

In case of MIX is used, rsnd_dma_attach() will be called twice from SSI.
To avoid duplicate allocation, current rsnd_dma_attach() is checking
allocated DMA handler. This DMA related operation is a little bit
difficult to understand.
This patch adds new rsnd_dma_alloc() and separates allocation and attach
for readable code.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-21 17:50:48 +01:00
Kuninori Morimoto b7165d26bf ASoC: rsnd: fix ADG flags
Current ADG driver is over-writing flags. This patch fixes it.

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-09-13 09:44:07 -07:00
Mark Brown 7d630ce4d6 Merge remote-tracking branches 'asoc/topic/dwc', 'asoc/topic/es8316', 'asoc/topic/fsi', 'asoc/topic/fsl' and 'asoc/topic/hdmi' into asoc-next 2017-09-01 12:12:36 +01:00
Mark Brown 94e26c0700 Merge remote-tracking branch 'asoc/topic/rcar' into asoc-next 2017-09-01 12:12:20 +01:00
Mark Brown 1a34ec4ab2 Merge remote-tracking branch 'asoc/fix/rcar' into asoc-linus 2017-09-01 12:12:12 +01:00
Kuninori Morimoto c16293560a ASoC: rsnd: remove unused rsnd_xxx_to_dma()
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-22 16:30:57 +01:00
Kuninori Morimoto b65cb7a590 ASoC: rsnd: tidyup comments position/space/tab
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-21 16:58:16 +01:00
Bhumika Goyal a46d0592d1 ASoC: sh: make snd_soc_ops const
Make this const as it is only stored in the ops field of a
snd_soc_dai_link structure, which is const.
Done using Coccinelle.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-17 18:09:48 +01:00
Bhumika Goyal 5c2e035e69 ASoC: sh: make snd_pcm_hardware const
Make these const as they are only passed as the 2nd argument to the
function snd_soc_set_runtime_hwparams, which is const.
Done using Coccinelle.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-17 17:57:21 +01:00
Mark Brown ce25f0d6e7 Merge branch 'topic/sh' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-rcar 2017-08-14 17:53:16 +01:00
Markus Elfring dd80627d06 ASoC: fsi: Delete an error message for a failed memory allocation in fsi_probe()
Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-14 17:37:44 +01:00
Arvind Yadav b23bd34c40 ASoC: sh: constify snd_pcm_ops structures
snd_pcm_ops are not supposed to change at runtime. All functions
working with snd_pcm_ops provided by <sound/soc.h> work with
const snd_pcm_ops. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-14 17:23:43 +01:00
Bhumika Goyal 5177255451 ASoC: sh: make snd_soc_platform_driver const
Make these const as they are either passed as the 2nd argument to
the function devm_snd_soc_register_platform or snd_soc_register_platform,
and the arguments are of type const.
Done using Coccinelle.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-14 17:21:02 +01:00
Markus Elfring 0d7820d091 ASoC: rsnd: Delete an error message for a failed memory allocation in three functions
Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-10 16:32:38 +01:00
Kuninori Morimoto b6e58fcacb ASoC: rsnd: call request_irq/free_irq once in MIX case
Each module's dai callback function availability is controlled
by mod->status. For example "always called", "call once".
In .probe/.remove case, it needs to be called always, because
.probe will call xxx_attach() function on .probe, especially
if platform is using MIXer.
For example, below case, MIX0/DVC0/SSI0 needs to be called twice.

        playback = <&src0 &ctu02 &mix0 &dvc0 &ssi0>;
        playback = <&src2 &ctu03 &mix0 &dvc0 &ssi0>;

But in this case, SSI0 will call request_irq() twice.
This patch add new RSND_SSI_PROBED flag and control it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-10 16:07:04 +01:00
Kuninori Morimoto bf9b29c784 ASoC: rsnd: add rsnd_ssi_flags_has/add() macro
Current rsnd_ssi_mode_flags() is not useful. This patch adds
new rsnd_ssi_flags_has/add() macro for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-10 16:07:00 +01:00
Kuninori Morimoto 213691c7e8 ASoC: rsnd: call free_irq() both DMA/PIO mode
commit 701172dca1 ("ASoC: rsnd: don't use devm_request_irq() for SSI")
exchanged devm_request_irq() to request_irq() for SSI, because SSI will
fallback into PIO mode if DMA doesn't work.
But, because of it, PIO mode needed to call free_irq() when removing,
not only DMA mode.
This patch call free_irq() both PIO/DMA. Otherwise, rsnd IRQ handler
will be increased if user tried many unbind/bind.

Fixes: 701172dca1 ("ASoC: rsnd: don't use devm_request_irq() for SSI")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-10 16:06:56 +01:00
Mark Brown 880c15b1e6 Merge branch 'fix/rcar' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-rcar 2017-08-10 15:51:05 +01:00
Kuninori Morimoto e0936c3471 ASoC: rsnd: avoid duplicate free_irq()
commit 1f8754d4da ("ASoC: rsnd: don't call free_irq() on
Parent SSI") fixed Parent SSI duplicate free_irq().
But on Renesas Sound, not only Parent SSI but also Multi SSI
have same issue.
This patch avoid duplicate free_irq() if it was not pure SSI.

Fixes: 1f8754d4da ("ASoC: rsnd: don't call free_irq() on Parent SSI")
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-09 17:56:14 +01:00
Kuninori Morimoto 29d03ff5c7 ASoC: rsnd: remove 16ch support for now
R-Car Gen3 sound device can use TDM 16ch, but its usage is very
limited. It is not yet supported.
Let's remove unexpected/unsupported channel settings for now.
This patch makes xx_ADINR register settings sanity without
runtime check.

R-Car Gen3 datasheet

40.4.7 Note on Usage of the SSIU Module
When an SSIU module is used in "TDM-16ch mode",
only the transfer with the external memory is available.

Reported-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-09 17:56:14 +01:00
Kuninori Morimoto 597b046f0d ASoC: rsnd: control SSICR::EN correctly
In case of SSI0 playback, SSI1 capture, SSI0 might be shared for
clock output if clock master mode.

Current rsnd driver had been assumed that SSI clock contiguous
output which is needed for SSI parent needs SSICR::EN (SSI module
enable) bit.
But, this bit controls data input/output, not for clock.
Clock contiguous output needs SSICR : FORCE, SCKD, SWSD,
and SSIWSR : CONT. Not SSICR : EN.

Because of this wrong assumption, and insufficient control, on current
code, for example, if it starts SSI0(playback) -> SSI1(capture) order,
SSI0 SSICR::EN bit will temporarily be 0.
It causes playback side underrun error. This is bug.
We can reproduce this issue with SSI+SRC (without DVC), and capture
during playback operation.

This patch fixup current (wrong) assumption, and control SSICR::EN bit
correctly.

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:04:17 +01:00
Kuninori Morimoto bb002f925a ASoC: rsnd: rsnd_ssi_can_output_clk() macro
For example SSI0/SSI1 case, SSI1 can share pin with SSI0.
And then, SSI1 needs SSI0's clock.
This clock controlling is very picky and difficult to understand
in current code.

This patch adds new rsnd_ssi_can_output_clk() macro,
the code will be more understandable.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:03:50 +01:00
Kuninori Morimoto bf23c6a381 ASoC: rsnd: move rsnd_ssi_config_init() execute condition into it.
Make it the same style as other functions

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-08 12:03:49 +01:00
Kuninori Morimoto e3c6de4813 ASoC: rcar: unregister fixed rate on ADG
ADG is registering fixed rate clock for audio_clkout, but it had not
been unregister clock when removing.

Salvator-X board is using ak4613 driver now, and it supports
hw_constraints from commit 907cd8809e ("ASoC: ak4613: add
hw_constraint rule for Sampling Rate").
And this calculation is using input clk. This ak4613 input clock is
ADG clkout on Salvator-X.

Because ADG had not been unregister clkout when unbinding, it receives
fixed rate clk register error when re-binding.
Thus, ak4613 can't get correct input clock, and hw_constraints will be
failed after re-binding.
This means Salvator-X board can't use sound after unbind/bind.

This patch solves this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-08-02 12:06:16 +01:00
Kuninori Morimoto 3c9736aa1a ASoC: rsnd: merge snd_pcm_ops::open and snd_soc_dai_ops::startup
Current rsnd driver has snd_pcm_ops::open and snd_soc_dai_ops::startup,
but, these are called from soc_pcm_open in same time.
This patch merge these into rsnd_soc_dai_startup()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-28 11:16:51 +01:00
Kuninori Morimoto 16d4498962 ASoC: rsnd: don't use private_value on rsnd_kctrl_new()
Current rsnd kctrl is using both .private_value (for rsnd_kctrl_cfg)
and .private_data (for rsnd_mod) on snd_kcontrol.
But only 1 private data (= rsnd_kctrl_cfg) can be enough if it has
rsnd_mod pointer.
This patch doesn't use private_value.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-24 16:26:50 +01:00
Kuninori Morimoto 295c5ba4c0 ASoC: sh: hac: add missing "int ret"
commit b047e1cce8 ("ASoC: ac97: Support multi-platform AC'97")
modified hac_soc_platform_probe(), but "int ret" was missed.
This patch adds missing "int ret", otherwise, we will get

linux/sound/soc/sh/hac.c: In function 'hac_soc_platform_probe':
linux/sound/soc/sh/hac.c:318: error: 'ret' undeclared (first use in this function)
linux/sound/soc/sh/hac.c:318: error: (Each undeclared identifier is reported only once
linux/sound/soc/sh/hac.c:318: error: for each function it appears in.)

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-24 13:06:53 +01:00
Gustavo A. R. Silva 32e1b60d8f ASoC: rsnd: remove unnecessary static in rsnd_ssiu_probe()
Remove unnecessary static on local variable ops.
Such variable is initialized before being used,
on every execution path throughout the function.
The static has no benefit and, removing it reduces
the code size.

This issue was detected using Coccinelle and the following semantic patch:

@bad exists@
position p;
identifier x;
type T;
@@

static T x@p;
...
x = <+...x...+>

@@
identifier x;
expression e;
type T;
position p != bad.p;
@@

-static
 T x@p;
 ... when != x
     when strict
?x = e;

In the following log you can see the difference in the code size. Also,
there is a significant difference in the bss segment. This log is the
output of the size command, before and after the code change:

before:
   text    data     bss     dec     hex filename
   3211     680      64    3955     f73 sound/soc/sh/rcar/ssiu.o

after:
   text    data     bss     dec     hex filename
   3207     592       0    3799     ed7 sound/soc/sh/rcar/ssiu.o

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17 17:00:57 +01:00
Julia Lawall 53ba2aa314 ASoC: rsnd: add missing of_node_put
for_each_child_of_node performs an of_node_get on each iteration, so a
jump out of the loop requires an of_node_put.

The semantic patch that fixes this problem is as follows
(http://coccinelle.lip6.fr):

// <smpl>
@@
local idexpression n;
expression e,e1;
identifier l;
@@

 for_each_child_of_node(e1,n) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  goto l;
)
   ...
 }
...
l: ... when != n
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17 15:39:51 +01:00
Gustavo A. R. Silva 4b2983da22 ASoC: fsi: constify dev_pm_ops structure
This dev_pm_ops structure is only stored in the pm field of a
device_driver structure. This field is declared const, so
dev_pm_ops structures that have this property can be declared
as const also.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-07-17 15:16:16 +01:00
Takashi Iwai 818a23e388 ASoC: Updates for v4.13
The big news with this release is the of-graph card, this provides a
 replacement for simple-card that is much more flexibile and scalable,
 allowing many more systems to use a generic sound card than was possible
 before:
 
  - The of-graph card, finally merged after a long and dedicated effort
    by Morimoto-san.
  - New widget types intended mainly for use with DSPs.
  - New drivers for Allwinner V3s SoCs, Ensonic ES8316, several classes
    of x86 machine, Rockchip PDM controllers, STM32 I2S and S/PDIF
    controllers and ZTE AUD96P22 CODECs.
 -----BEGIN PGP SIGNATURE-----
 
 iQFHBAABCAAxFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAllaa7wTHGJyb29uaWVA
 a2VybmVsLm9yZwAKCRAk1otyXVSH0MhRB/0cIuUi/SmMSGz7cNKdDDArdpxHUV0U
 dJb6qqhXCKeDQcx/34b1m+BnZpeT9au4Nt8HxOlLRbumcnuesYqfeBeZvuJhsC4I
 q3e8e+idQlOp3+WM+snUXhWM4P/UsA9H4BaV1jvYSQW/C9WhfuLxsOraRiebLH7u
 WJkmfeVjpzHHWzfDtpWJLHVroRLLMbOaz0e0Pw8/R1dfof0u27zKknqHOUcwRg0N
 4+IWvKn3p59VE6eM6QUmruMZZCCfn2Hv5RygWf3LaHVlhA28BZi0dyMMSSSzVG6o
 Im1Wm5z0dmmTfQKdNDU3PPBEKG6amTqF+2uuXOsq1I7vuiT+akHZbgWW
 =F5BP
 -----END PGP SIGNATURE-----

Merge tag 'asoc-v4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus

ASoC: Updates for v4.13

The big news with this release is the of-graph card, this provides a
replacement for simple-card that is much more flexibile and scalable,
allowing many more systems to use a generic sound card than was possible
before:

 - The of-graph card, finally merged after a long and dedicated effort
   by Morimoto-san.
 - New widget types intended mainly for use with DSPs.
 - New drivers for Allwinner V3s SoCs, Ensonic ES8316, several classes
   of x86 machine, Rockchip PDM controllers, STM32 I2S and S/PDIF
   controllers and ZTE AUD96P22 CODECs.
2017-07-03 19:51:42 +02:00
Mark Brown cf1f9e5d16 Merge remote-tracking branches 'asoc/topic/samsung', 'asoc/topic/sgtl5000' and 'asoc/topic/sh' into asoc-next 2017-07-03 16:15:19 +01:00
Colin Ian King 8288591368 ASoC: rsnd: make arrays path and cmd_case static const
Don't populate the arrays path and cmd_case on the stack but make
them static const.  Makes the object code smaller:

Before:
   text    data     bss     dec     hex filename
   2673     624       0    3297     ce1 sound/soc/sh/rcar/cmd.o

After:
   text    data     bss     dec     hex filename
   2398     768       0    3166     c5e sound/soc/sh/rcar/cmd.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-30 12:45:36 +01:00
Arvind Yadav 49ebf13b04 ASoC: rsnd: constify dev_pm_ops structures.
dev_pm_ops are not supposed to change at runtime. All functions
working with dev_pm_ops provided by <linux/device.h> work with const
dev_pm_ops. So mark the non-const structs as const.

File size before:
   text	   data	    bss	    dec	    hex	filename
   8172	    920	      0	   9092	   2384	sound/soc/sh/rcar/core.o

File size After adding 'const':
   text	   data	    bss	    dec	    hex	filename
   8364	    728	      0	   9092	   2384	sound/soc/sh/rcar/core.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-30 12:17:32 +01:00
Kuninori Morimoto 947f4eb58d ASoC: rsnd: fixup unsigned expression compared with zero: main_rate
This patch fixes this WARNING

sound/soc/sh/rcar/ssi.c:285:5-14: WARNING: Unsigned expression\
	compared with zero: main_rate < 0

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-21 12:14:04 +01:00
Kuninori Morimoto 8cc0372240 ASoC: rsnd: add rsnd_soc_hw_rule/constraint()
Current Renesas sound driver is assuming that all Sampling rate and
channles are possible to use, but these are depends on inputed clock
and SSI connection situation.
For example, if it is using 1 SSI, enabled TDM mode and has 12288000
input clock, 2ch output can support until 192000Hz, but 6ch output can
support until 64000Hz, 8ch can support 48000Hz.
To control these situation correctly, it needs to support
hw_constraints / refine feature.

To support such feature, this patch adds new
rsnd_soc_hw_rule/constraint() which adds hw rule of Channel and
Sampling Rate.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-15 18:18:08 +01:00
Kuninori Morimoto ef4cf5d6a1 ASoC: rsnd: add rsnd_ssi_clk_query()
Current Renesas sound driver is assuming that all Sampling rate and
channles are possible to use, but these are depends on inputed clock
and SSI connection situation.
For example, if it is using 1 SSI, enabled TDM mode and has 12288000
input clock, 2ch output can support until 192000Hz, but 6ch output can
support until 64000Hz, 8ch can support 48000Hz.
To control these situation correctly, it needs to support
hw_constraints / refine feature.

To support such feature, this patch adds new rsnd_ssi_clk_query().

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-15 18:18:05 +01:00
Kuninori Morimoto 1dfdc6501a ASoC: rsnd: add rsnd_adg_clk_query()
Current Renesas sound driver is assuming that all Sampling rate and
channles are possible to use, but these are depends on inputed clock
and SSI connection situation.
For example, if it is using 1 SSI, enabled TDM mode and has 12288000
input clock, 2ch output can support until 192000Hz, but 6ch output can
support until 64000Hz, 8ch can support 48000Hz.
To control these situation correctly, it needs to support
hw_constraints / refine feature.

To support such feature, it needs SSI clock query feature, and it needs
ADG clock query feature. Current ADG has rsnd_adg_ssi_clk_try_start()
and it is doing similar things, but it try to setup ADG register in
same time. This is not needed.

This patch adds new rsnd_adg_clk_query() and separates query feature
and register setting feature in adg.c

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-15 18:18:02 +01:00
Kuninori Morimoto 1ff9593d2f ASoC: rsnd: rename "slots" related variable
Current Renesas sound driver has slots and slots_num in
struct rsnd_dai, but these are very un-understandable naming
(It had named from TDM slots).
In this driver, the "slots" means total usable channels, and
"stot_num" means SSI lane number if Multi SSI was used.
To more understandable code, this patch renames "slots" to
"max_channels", and "slots_num" to "ssi_lane", and replaces related
functions name.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-15 18:17:54 +01:00
Kuninori Morimoto f30b4ca444 ASoC: rsnd: reduce confusable macro parameter magic
rsnd_dai_call() macro is using "priv" inside.
Thus, if caller function doesn't have "priv" related operation, strange
phenomenon occur which code is using "priv", but compiler indicates
"unused variable 'priv'".

>From code point of view, it is not problem, but it is very confusable.
This patch removes "priv" from rsnd_dai_call() macro, and adds "priv"
on caller function.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-14 10:47:25 +01:00
Kuninori Morimoto f0b04d8b44 ASoC: rsnd: control kctrl items acceptance anytime/runtime
Current SRC/DVC/CTU adds kctrl for each device,
and SRC can adjust its sampling rate during playback,
thus, this feature should be enabled only *during* playback.
This patch controls it more clearly

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-13 21:38:45 +01:00
Kuninori Morimoto 8cce431aa2 ASoC: rsnd: add detail explanation of L/R conversion timing
Renesas Sound device *Hardware* L/R and Linux *Software* L/R are
inverted. Because of this background, it needs to convert L/R.
Then, DVC needs *Hardware* L/R, and Linux needs *Software* L/R.
Because Playback/Capture needs different timing, and there is no
explanation about it on source code / git log, this patch adds it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-13 21:38:42 +01:00
Kuninori Morimoto a97a06c7ef ASoC: rsnd: cleanup pointer related code
Current rsnd driver is sharing pointer related code between
PIO / DMA. But, it is used only PIO mode now, no longer needed.
This patch cleanup these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-07 20:30:38 +01:00
Mark Brown 9bc3b4ff18 Merge branch 'fix/rcar' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-rcar 2017-06-07 20:30:32 +01:00
Kuninori Morimoto 07b7acb51d ASoC: rsnd: update pointer more accurate
Current rsnd driver updates pointer when DMA transfer was finished
in DMA transfer mode. But PulseAudio requests more accurate
pointer update when timer mode.
This patch consider about DMA transfer residue and update more
accurate pointer.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-07 20:30:03 +01:00
Takashi Iwai 4c7aba46c9 Merge branch 'for-linus' into for-next
For applying more ALSA timer cleanups.
2017-06-07 10:25:30 +02:00
Kuninori Morimoto d70c34db33 ASoC: rsnd: remove unused rsnd_dai_path_info
commit 2ea2cc86db ("ASoC: rsnd: remove struct rcar_snd_info")
removed all struct rsnd_dai_path_info related code.
This patch removes unused rsnd_dai_path_info.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 17:55:08 +01:00
Kuninori Morimoto f07b38e53b ASoC: rsnd: remove unused rsnd_ssi_non_ops
rsnd_ssi_non_ops is never used. Let's remove it

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-06-06 17:55:08 +01:00
Bhumika Goyal 905e46acd3 ALSA: declare snd_kcontrol_new structures as const
Declare snd_kcontrol_new structures as const as they are only passed an
argument to the function snd_ctl_new1. This argument is of type const,
so snd_kcontrol_new structures having this property can be made const.
Done using Coccinelle:

@r disable optional_qualifier@
identifier x;
position p;
@@
static struct snd_kcontrol_new x@p={...};

@ok@
identifier r.x;
position p;
@@
snd_ctl_new1(&x@p,...)

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct snd_kcontrol_new x;

Cross compiled these files:
sound/aoa/codecs/tas.c - powerpc
sound/mips/{hal2.c/sgio2audio.c} - mips
sound/ppc/{awacs.c/beep.c/tumbler.c} - powerpc
sound/soc/sh/siu_dai.c - sh
Could not find an architecture to compile sound/sh/aica.c.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-05-30 10:29:25 +02:00
Kuninori Morimoto e8a3ce1130 ASoC: rsnd: fixup parent_clk_name of AUDIO_CLKOUTx
commit 25165f79ad ("ASoC: rsnd: enable clock-frequency for both
44.1kHz/48kHz") supported both 44.1kHz/48kHz for AUDIO_CLKOUTx,
but it didn't care its parent clock name.
This patch fixes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-26 12:39:07 +01:00
Kuninori Morimoto 7819a942de ASoC: rsnd: SSI PIO adjust to 24bit mode
commit 90431eb49b ("ASoC: rsnd: don't use PDTA bit for 24bit on SSI")
fixups 24bit mode data alignment, but PIO was not cared.
This patch fixes PIO mode 24bit data alignment

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-24 18:11:47 +01:00
Kuninori Morimoto 7fa72cca39 ASoC: rsnd: add HDMI output support
Renesas R-Car Gen3 can output HDMI sound if SSIU/SSI are connected to
R-Car built-in HDMI device (R-Car Gen3 built-in HDMI device will be
controlled by DRM/KMS driver).
If SSIx was connected to HDMI0/1 on DT, SSI driver will detect it
automatically by this patch.
Note is that now Renesas R-Car sound driver is assuming that it is
using OF-graph base simple card for HDMI sound.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-19 18:36:25 +01:00
Kuninori Morimoto 4d4b334bda ASoC: rsnd: add support graph base DT phase 2
To enable OF-graph base DT on rsnd driver, and to keep compatible
previous normal sound card style, it need to support both
"rcar_sound,dai" and "ports" (or "port") on DT.

This patch parses both style.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-19 18:36:25 +01:00
Kuninori Morimoto 11d0f8ed6d ASoC: rsnd: add support graph base DT phase 1
To enable OF-graph base DT on rsnd driver, and to keep compatible
previous normal sound card style, it need to support both
"rcar_sound,dai" and "ports" (or "port") on DT.

This patch modify rsnd_dai_of_node() to parse
"rcar_sound,dai" and "ports" (or "port") as phase 1. It can detect
graph base style, but do nothing at this point.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-19 18:36:25 +01:00
Kuninori Morimoto 1f8754d4da ASoC: rsnd: don't call free_irq() on Parent SSI
If SSI uses shared pin, some SSI will be used as parent SSI.
Then, normal SSI's remove and Parent SSI's remove
(these are same SSI) will be called when unbind or remove timing.
In this case, free_irq() will be called twice.
This patch solve this issue.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-19 17:32:09 +01:00
Kuninori Morimoto 90431eb49b ASoC: rsnd: don't use PDTA bit for 24bit on SSI
Current SSI uses PDTA bit which indicates data that Input/Output
data are Right-Aligned. But, 24bit sound should be Left-Aligned
in this HW. Because Linux is using Right-Aligned data, and HW uses
Left-Aligned data, current 24bit data is missing lower 8bit.
To fix this issue, this patch removes PDTA bit, and shift 8bit
in necessary module

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-17 10:49:45 +01:00
Geert Uytterhoeven 3048e76c93 ASoC: fsi: Move inline fsi_stream_is_play() before use
With gcc 4.1.2:

    sound/soc/sh/fsi.c:304: warning: ‘fsi_stream_is_play’ declared inline after being called
    sound/soc/sh/fsi.c:304: warning: previous declaration of ‘fsi_stream_is_play’ was here

Move fsi_stream_is_play() up to fix this, removing the need for a
forward declaration as well.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-05-17 10:36:05 +01:00