0363-Change-BoomBerry-name-to-JustBoom-in-all-locations-d.patch 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  1. From 6a5d72f7ea13b48840353fd22f672dc3af8b9fc5 Mon Sep 17 00:00:00 2001
  2. From: Aaron Shaw <shawaj@gmail.com>
  3. Date: Thu, 26 May 2016 23:37:11 +0100
  4. Subject: [PATCH] Change BoomBerry name to JustBoom in all locations due to
  5. legal challenge
  6. ---
  7. arch/arm/boot/dts/overlays/Makefile | 4 +-
  8. arch/arm/boot/dts/overlays/README | 52 ++---
  9. .../boot/dts/overlays/boomberry-dac-overlay.dts | 43 -----
  10. .../boot/dts/overlays/boomberry-digi-overlay.dts | 39 ----
  11. .../arm/boot/dts/overlays/justboom-dac-overlay.dts | 43 +++++
  12. .../boot/dts/overlays/justboom-digi-overlay.dts | 39 ++++
  13. arch/arm/configs/bcm2709_defconfig | 4 +-
  14. arch/arm/configs/bcmrpi_defconfig | 4 +-
  15. sound/soc/bcm/Kconfig | 12 +-
  16. sound/soc/bcm/Makefile | 8 +-
  17. sound/soc/bcm/boomberry-dac.c | 162 ----------------
  18. sound/soc/bcm/boomberry-digi.c | 215 ---------------------
  19. sound/soc/bcm/justboom-dac.c | 162 ++++++++++++++++
  20. sound/soc/bcm/justboom-digi.c | 215 +++++++++++++++++++++
  21. 14 files changed, 501 insertions(+), 501 deletions(-)
  22. delete mode 100644 arch/arm/boot/dts/overlays/boomberry-dac-overlay.dts
  23. delete mode 100644 arch/arm/boot/dts/overlays/boomberry-digi-overlay.dts
  24. create mode 100644 arch/arm/boot/dts/overlays/justboom-dac-overlay.dts
  25. create mode 100644 arch/arm/boot/dts/overlays/justboom-digi-overlay.dts
  26. delete mode 100644 sound/soc/bcm/boomberry-dac.c
  27. delete mode 100644 sound/soc/bcm/boomberry-digi.c
  28. create mode 100644 sound/soc/bcm/justboom-dac.c
  29. create mode 100644 sound/soc/bcm/justboom-digi.c
  30. --- a/arch/arm/boot/dts/overlays/Makefile
  31. +++ b/arch/arm/boot/dts/overlays/Makefile
  32. @@ -18,8 +18,6 @@ dtbo-$(RPI_DT_OVERLAYS) += akkordion-iqd
  33. dtbo-$(RPI_DT_OVERLAYS) += at86rf233.dtbo
  34. dtbo-$(RPI_DT_OVERLAYS) += audioinjector-wm8731-audio.dtbo
  35. dtbo-$(RPI_DT_OVERLAYS) += bmp085_i2c-sensor.dtbo
  36. -dtbo-$(RPI_DT_OVERLAYS) += boomberry-dac.dtbo
  37. -dtbo-$(RPI_DT_OVERLAYS) += boomberry-digi.dtbo
  38. dtbo-$(RPI_DT_OVERLAYS) += dpi24.dtbo
  39. dtbo-$(RPI_DT_OVERLAYS) += dwc2.dtbo
  40. dtbo-$(RPI_DT_OVERLAYS) += dwc-otg.dtbo
  41. @@ -43,6 +41,8 @@ dtbo-$(RPI_DT_OVERLAYS) += i2s-gpio28-31
  42. dtbo-$(RPI_DT_OVERLAYS) += i2s-mmap.dtbo
  43. dtbo-$(RPI_DT_OVERLAYS) += iqaudio-dac.dtbo
  44. dtbo-$(RPI_DT_OVERLAYS) += iqaudio-dacplus.dtbo
  45. +dtbo-$(RPI_DT_OVERLAYS) += justboom-dac.dtbo
  46. +dtbo-$(RPI_DT_OVERLAYS) += justboom-digi.dtbo
  47. dtbo-$(RPI_DT_OVERLAYS) += lirc-rpi.dtbo
  48. dtbo-$(RPI_DT_OVERLAYS) += mcp2515-can0.dtbo
  49. dtbo-$(RPI_DT_OVERLAYS) += mcp2515-can1.dtbo
  50. --- a/arch/arm/boot/dts/overlays/README
  51. +++ b/arch/arm/boot/dts/overlays/README
  52. @@ -238,32 +238,6 @@ Load: dtoverlay=bmp085_i2c-sensor
  53. Params: <None>
  54. -Name: boomberry-dac
  55. -Info: Configures the BoomBerry DAC HAT, Amp HAT, DAC Zero and Amp Zero audio
  56. - cards
  57. -Load: dtoverlay=boomberry-dac,<param>=<val>
  58. -Params: 24db_digital_gain Allow gain to be applied via the PCM512x codec
  59. - Digital volume control. Enable with
  60. - "dtoverlay=boomberry-dac,24db_digital_gain"
  61. - (The default behaviour is that the Digital
  62. - volume control is limited to a maximum of
  63. - 0dB. ie. it can attenuate but not provide
  64. - gain. For most users, this will be desired
  65. - as it will prevent clipping. By appending
  66. - the 24dB_digital_gain parameter, the Digital
  67. - volume control will allow up to 24dB of
  68. - gain. If this parameter is enabled, it is the
  69. - responsibility of the user to ensure that
  70. - the Digital volume control is set to a value
  71. - that does not result in clipping/distortion!)
  72. -
  73. -
  74. -Name: boomberry-digi
  75. -Info: Configures the BoomBerry Digi HAT and Digi Zero audio cards
  76. -Load: dtoverlay=boomberry-digi
  77. -Params: <None>
  78. -
  79. -
  80. Name: dht11
  81. Info: Overlay for the DHT11/DHT21/DHT22 humidity/temperature sensors
  82. Also sometimes found with the part number(s) AM230x.
  83. @@ -541,6 +515,32 @@ Params: 24db_digital_gain Allow ga
  84. that does not result in clipping/distortion!)
  85. +Name: justboom-dac
  86. +Info: Configures the JustBoom DAC HAT, Amp HAT, DAC Zero and Amp Zero audio
  87. + cards
  88. +Load: dtoverlay=justboom-dac,<param>=<val>
  89. +Params: 24db_digital_gain Allow gain to be applied via the PCM512x codec
  90. + Digital volume control. Enable with
  91. + "dtoverlay=justboom-dac,24db_digital_gain"
  92. + (The default behaviour is that the Digital
  93. + volume control is limited to a maximum of
  94. + 0dB. ie. it can attenuate but not provide
  95. + gain. For most users, this will be desired
  96. + as it will prevent clipping. By appending
  97. + the 24dB_digital_gain parameter, the Digital
  98. + volume control will allow up to 24dB of
  99. + gain. If this parameter is enabled, it is the
  100. + responsibility of the user to ensure that
  101. + the Digital volume control is set to a value
  102. + that does not result in clipping/distortion!)
  103. +
  104. +
  105. +Name: justboom-digi
  106. +Info: Configures the JustBoom Digi HAT and Digi Zero audio cards
  107. +Load: dtoverlay=justboom-digi
  108. +Params: <None>
  109. +
  110. +
  111. Name: lirc-rpi
  112. Info: Configures lirc-rpi (Linux Infrared Remote Control for Raspberry Pi)
  113. Consult the module documentation for more details.
  114. --- a/arch/arm/boot/dts/overlays/boomberry-dac-overlay.dts
  115. +++ /dev/null
  116. @@ -1,43 +0,0 @@
  117. -// Definitions for BoomBerry DAC
  118. -/dts-v1/;
  119. -/plugin/;
  120. -
  121. -/ {
  122. - compatible = "brcm,bcm2708";
  123. -
  124. - fragment@0 {
  125. - target = <&i2s>;
  126. - __overlay__ {
  127. - status = "okay";
  128. - };
  129. - };
  130. -
  131. - fragment@1 {
  132. - target = <&i2c1>;
  133. - __overlay__ {
  134. - #address-cells = <1>;
  135. - #size-cells = <0>;
  136. - status = "okay";
  137. -
  138. - pcm5122@4d {
  139. - #sound-dai-cells = <0>;
  140. - compatible = "ti,pcm5122";
  141. - reg = <0x4d>;
  142. - status = "okay";
  143. - };
  144. - };
  145. - };
  146. -
  147. - fragment@2 {
  148. - target = <&sound>;
  149. - frag2: __overlay__ {
  150. - compatible = "boomberry,boomberry-dac";
  151. - i2s-controller = <&i2s>;
  152. - status = "okay";
  153. - };
  154. - };
  155. -
  156. - __overrides__ {
  157. - 24db_digital_gain = <&frag2>,"boomberry,24db_digital_gain?";
  158. - };
  159. -};
  160. --- a/arch/arm/boot/dts/overlays/boomberry-digi-overlay.dts
  161. +++ /dev/null
  162. @@ -1,39 +0,0 @@
  163. -// Definitions for BoomBerry Digi
  164. -/dts-v1/;
  165. -/plugin/;
  166. -
  167. -/ {
  168. - compatible = "brcm,bcm2708";
  169. -
  170. - fragment@0 {
  171. - target = <&i2s>;
  172. - __overlay__ {
  173. - status = "okay";
  174. - };
  175. - };
  176. -
  177. - fragment@1 {
  178. - target = <&i2c1>;
  179. - __overlay__ {
  180. - #address-cells = <1>;
  181. - #size-cells = <0>;
  182. - status = "okay";
  183. -
  184. - wm8804@3b {
  185. - #sound-dai-cells = <0>;
  186. - compatible = "wlf,wm8804";
  187. - reg = <0x3b>;
  188. - status = "okay";
  189. - };
  190. - };
  191. - };
  192. -
  193. - fragment@2 {
  194. - target = <&sound>;
  195. - __overlay__ {
  196. - compatible = "boomberry,boomberry-digi";
  197. - i2s-controller = <&i2s>;
  198. - status = "okay";
  199. - };
  200. - };
  201. -};
  202. --- /dev/null
  203. +++ b/arch/arm/boot/dts/overlays/justboom-dac-overlay.dts
  204. @@ -0,0 +1,43 @@
  205. +// Definitions for JustBoom DAC
  206. +/dts-v1/;
  207. +/plugin/;
  208. +
  209. +/ {
  210. + compatible = "brcm,bcm2708";
  211. +
  212. + fragment@0 {
  213. + target = <&i2s>;
  214. + __overlay__ {
  215. + status = "okay";
  216. + };
  217. + };
  218. +
  219. + fragment@1 {
  220. + target = <&i2c1>;
  221. + __overlay__ {
  222. + #address-cells = <1>;
  223. + #size-cells = <0>;
  224. + status = "okay";
  225. +
  226. + pcm5122@4d {
  227. + #sound-dai-cells = <0>;
  228. + compatible = "ti,pcm5122";
  229. + reg = <0x4d>;
  230. + status = "okay";
  231. + };
  232. + };
  233. + };
  234. +
  235. + fragment@2 {
  236. + target = <&sound>;
  237. + frag2: __overlay__ {
  238. + compatible = "justboom,justboom-dac";
  239. + i2s-controller = <&i2s>;
  240. + status = "okay";
  241. + };
  242. + };
  243. +
  244. + __overrides__ {
  245. + 24db_digital_gain = <&frag2>,"justboom,24db_digital_gain?";
  246. + };
  247. +};
  248. --- /dev/null
  249. +++ b/arch/arm/boot/dts/overlays/justboom-digi-overlay.dts
  250. @@ -0,0 +1,39 @@
  251. +// Definitions for JustBoom Digi
  252. +/dts-v1/;
  253. +/plugin/;
  254. +
  255. +/ {
  256. + compatible = "brcm,bcm2708";
  257. +
  258. + fragment@0 {
  259. + target = <&i2s>;
  260. + __overlay__ {
  261. + status = "okay";
  262. + };
  263. + };
  264. +
  265. + fragment@1 {
  266. + target = <&i2c1>;
  267. + __overlay__ {
  268. + #address-cells = <1>;
  269. + #size-cells = <0>;
  270. + status = "okay";
  271. +
  272. + wm8804@3b {
  273. + #sound-dai-cells = <0>;
  274. + compatible = "wlf,wm8804";
  275. + reg = <0x3b>;
  276. + status = "okay";
  277. + };
  278. + };
  279. + };
  280. +
  281. + fragment@2 {
  282. + target = <&sound>;
  283. + __overlay__ {
  284. + compatible = "justboom,justboom-digi";
  285. + i2s-controller = <&i2s>;
  286. + status = "okay";
  287. + };
  288. + };
  289. +};
  290. --- a/arch/arm/configs/bcm2709_defconfig
  291. +++ b/arch/arm/configs/bcm2709_defconfig
  292. @@ -861,8 +861,8 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
  293. CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
  294. CONFIG_SND_BCM2708_SOC_RPI_DAC=m
  295. CONFIG_SND_BCM2708_SOC_RPI_PROTO=m
  296. -CONFIG_SND_BCM2708_SOC_BOOMBERRY_DAC=m
  297. -CONFIG_SND_BCM2708_SOC_BOOMBERRY_DIGI=m
  298. +CONFIG_SND_BCM2708_SOC_JUSTBOOM_DAC=m
  299. +CONFIG_SND_BCM2708_SOC_JUSTBOOM_DIGI=m
  300. CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC=m
  301. CONFIG_SND_BCM2708_SOC_RASPIDAC3=m
  302. CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD=m
  303. --- a/arch/arm/configs/bcmrpi_defconfig
  304. +++ b/arch/arm/configs/bcmrpi_defconfig
  305. @@ -853,8 +853,8 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
  306. CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
  307. CONFIG_SND_BCM2708_SOC_RPI_DAC=m
  308. CONFIG_SND_BCM2708_SOC_RPI_PROTO=m
  309. -CONFIG_SND_BCM2708_SOC_BOOMBERRY_DAC=m
  310. -CONFIG_SND_BCM2708_SOC_BOOMBERRY_DIGI=m
  311. +CONFIG_SND_BCM2708_SOC_JUSTBOOM_DAC=m
  312. +CONFIG_SND_BCM2708_SOC_JUSTBOOM_DIGI=m
  313. CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC=m
  314. CONFIG_SND_BCM2708_SOC_RASPIDAC3=m
  315. CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD=m
  316. --- a/sound/soc/bcm/Kconfig
  317. +++ b/sound/soc/bcm/Kconfig
  318. @@ -50,19 +50,19 @@ config SND_BCM2708_SOC_RPI_PROTO
  319. help
  320. Say Y or M if you want to add support for Audio Codec Board PROTO (WM8731).
  321. -config SND_BCM2708_SOC_BOOMBERRY_DAC
  322. - tristate "Support for BoomBerry DAC"
  323. +config SND_BCM2708_SOC_JUSTBOOM_DAC
  324. + tristate "Support for JustBoom DAC"
  325. depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
  326. select SND_SOC_PCM512x
  327. help
  328. - Say Y or M if you want to add support for BoomBerry DAC.
  329. + Say Y or M if you want to add support for JustBoom DAC.
  330. -config SND_BCM2708_SOC_BOOMBERRY_DIGI
  331. - tristate "Support for BoomBerry Digi"
  332. +config SND_BCM2708_SOC_JUSTBOOM_DIGI
  333. + tristate "Support for JustBoom Digi"
  334. depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
  335. select SND_SOC_WM8804
  336. help
  337. - Say Y or M if you want to add support for BoomBerry Digi.
  338. + Say Y or M if you want to add support for JustBoom Digi.
  339. config SND_BCM2708_SOC_IQAUDIO_DAC
  340. tristate "Support for IQaudIO-DAC"
  341. --- a/sound/soc/bcm/Makefile
  342. +++ b/sound/soc/bcm/Makefile
  343. @@ -9,8 +9,8 @@ snd-soc-hifiberry-dac-objs := hifiberry_
  344. snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
  345. snd-soc-hifiberry-digi-objs := hifiberry_digi.o
  346. snd-soc-hifiberry-amp-objs := hifiberry_amp.o
  347. -snd-soc-boomberry-dac-objs := boomberry-dac.o
  348. -snd-soc-boomberry-digi-objs := boomberry-digi.o
  349. +snd-soc-justboom-dac-objs := justboom-dac.o
  350. +snd-soc-justboom-digi-objs := justboom-digi.o
  351. snd-soc-rpi-dac-objs := rpi-dac.o
  352. snd-soc-rpi-proto-objs := rpi-proto.o
  353. snd-soc-iqaudio-dac-objs := iqaudio-dac.o
  354. @@ -22,8 +22,8 @@ obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_D
  355. obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
  356. obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) += snd-soc-hifiberry-digi.o
  357. obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP) += snd-soc-hifiberry-amp.o
  358. -obj-$(CONFIG_SND_BCM2708_SOC_BOOMBERRY_DAC) += snd-soc-boomberry-dac.o
  359. -obj-$(CONFIG_SND_BCM2708_SOC_BOOMBERRY_DIGI) += snd-soc-boomberry-digi.o
  360. +obj-$(CONFIG_SND_BCM2708_SOC_JUSTBOOM_DAC) += snd-soc-justboom-dac.o
  361. +obj-$(CONFIG_SND_BCM2708_SOC_JUSTBOOM_DIGI) += snd-soc-justboom-digi.o
  362. obj-$(CONFIG_SND_BCM2708_SOC_RPI_DAC) += snd-soc-rpi-dac.o
  363. obj-$(CONFIG_SND_BCM2708_SOC_RPI_PROTO) += snd-soc-rpi-proto.o
  364. obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) += snd-soc-iqaudio-dac.o
  365. --- a/sound/soc/bcm/boomberry-dac.c
  366. +++ /dev/null
  367. @@ -1,162 +0,0 @@
  368. -/*
  369. - * ASoC Driver for BoomBerry DAC Raspberry Pi HAT Sound Card
  370. - *
  371. - * Author: Milan Neskovic
  372. - * Copyright 2016
  373. - * based on code by Daniel Matuschek <info@crazy-audio.com>
  374. - * based on code by Florian Meier <florian.meier@koalo.de>
  375. - *
  376. - * This program is free software; you can redistribute it and/or
  377. - * modify it under the terms of the GNU General Public License
  378. - * version 2 as published by the Free Software Foundation.
  379. - *
  380. - * This program is distributed in the hope that it will be useful, but
  381. - * WITHOUT ANY WARRANTY; without even the implied warranty of
  382. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  383. - * General Public License for more details.
  384. - */
  385. -
  386. -#include <linux/module.h>
  387. -#include <linux/platform_device.h>
  388. -
  389. -#include <sound/core.h>
  390. -#include <sound/pcm.h>
  391. -#include <sound/pcm_params.h>
  392. -#include <sound/soc.h>
  393. -#include <sound/jack.h>
  394. -
  395. -#include "../codecs/pcm512x.h"
  396. -
  397. -static bool digital_gain_0db_limit = true;
  398. -
  399. -static int snd_rpi_boomberry_dac_init(struct snd_soc_pcm_runtime *rtd)
  400. -{
  401. - struct snd_soc_codec *codec = rtd->codec;
  402. - snd_soc_update_bits(codec, PCM512x_GPIO_EN, 0x08, 0x08);
  403. - snd_soc_update_bits(codec, PCM512x_GPIO_OUTPUT_4, 0xf, 0x02);
  404. - snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08,0x08);
  405. -
  406. - if (digital_gain_0db_limit)
  407. - {
  408. - int ret;
  409. - struct snd_soc_card *card = rtd->card;
  410. -
  411. - ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
  412. - if (ret < 0)
  413. - dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
  414. - }
  415. -
  416. - return 0;
  417. -}
  418. -
  419. -static int snd_rpi_boomberry_dac_hw_params(struct snd_pcm_substream *substream,
  420. - struct snd_pcm_hw_params *params)
  421. -{
  422. - struct snd_soc_pcm_runtime *rtd = substream->private_data;
  423. - struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  424. - /*return snd_soc_dai_set_bclk_ratio(cpu_dai, 64);*/
  425. - unsigned int sample_bits =
  426. - snd_pcm_format_physical_width(params_format(params));
  427. - return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2);
  428. -}
  429. -
  430. -static int snd_rpi_boomberry_dac_startup(struct snd_pcm_substream *substream) {
  431. - struct snd_soc_pcm_runtime *rtd = substream->private_data;
  432. - struct snd_soc_codec *codec = rtd->codec;
  433. - snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08,0x08);
  434. - return 0;
  435. -}
  436. -
  437. -static void snd_rpi_boomberry_dac_shutdown(struct snd_pcm_substream *substream) {
  438. - struct snd_soc_pcm_runtime *rtd = substream->private_data;
  439. - struct snd_soc_codec *codec = rtd->codec;
  440. - snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08,0x00);
  441. -}
  442. -
  443. -/* machine stream operations */
  444. -static struct snd_soc_ops snd_rpi_boomberry_dac_ops = {
  445. - .hw_params = snd_rpi_boomberry_dac_hw_params,
  446. - .startup = snd_rpi_boomberry_dac_startup,
  447. - .shutdown = snd_rpi_boomberry_dac_shutdown,
  448. -};
  449. -
  450. -static struct snd_soc_dai_link snd_rpi_boomberry_dac_dai[] = {
  451. -{
  452. - .name = "BoomBerry DAC",
  453. - .stream_name = "BoomBerry DAC HiFi",
  454. - .cpu_dai_name = "bcm2708-i2s.0",
  455. - .codec_dai_name = "pcm512x-hifi",
  456. - .platform_name = "bcm2708-i2s.0",
  457. - .codec_name = "pcm512x.1-004d",
  458. - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  459. - SND_SOC_DAIFMT_CBS_CFS,
  460. - .ops = &snd_rpi_boomberry_dac_ops,
  461. - .init = snd_rpi_boomberry_dac_init,
  462. -},
  463. -};
  464. -
  465. -/* audio machine driver */
  466. -static struct snd_soc_card snd_rpi_boomberry_dac = {
  467. - .name = "snd_rpi_boomberry_dac",
  468. - .owner = THIS_MODULE,
  469. - .dai_link = snd_rpi_boomberry_dac_dai,
  470. - .num_links = ARRAY_SIZE(snd_rpi_boomberry_dac_dai),
  471. -};
  472. -
  473. -static int snd_rpi_boomberry_dac_probe(struct platform_device *pdev)
  474. -{
  475. - int ret = 0;
  476. -
  477. - snd_rpi_boomberry_dac.dev = &pdev->dev;
  478. -
  479. - if (pdev->dev.of_node) {
  480. - struct device_node *i2s_node;
  481. - struct snd_soc_dai_link *dai = &snd_rpi_boomberry_dac_dai[0];
  482. - i2s_node = of_parse_phandle(pdev->dev.of_node,
  483. - "i2s-controller", 0);
  484. -
  485. - if (i2s_node) {
  486. - dai->cpu_dai_name = NULL;
  487. - dai->cpu_of_node = i2s_node;
  488. - dai->platform_name = NULL;
  489. - dai->platform_of_node = i2s_node;
  490. - }
  491. -
  492. - digital_gain_0db_limit = !of_property_read_bool(
  493. - pdev->dev.of_node, "boomberry,24db_digital_gain");
  494. - }
  495. -
  496. - ret = snd_soc_register_card(&snd_rpi_boomberry_dac);
  497. - if (ret)
  498. - dev_err(&pdev->dev,
  499. - "snd_soc_register_card() failed: %d\n", ret);
  500. -
  501. - return ret;
  502. -}
  503. -
  504. -static int snd_rpi_boomberry_dac_remove(struct platform_device *pdev)
  505. -{
  506. - return snd_soc_unregister_card(&snd_rpi_boomberry_dac);
  507. -}
  508. -
  509. -static const struct of_device_id snd_rpi_boomberry_dac_of_match[] = {
  510. - { .compatible = "boomberry,boomberry-dac", },
  511. - {},
  512. -};
  513. -MODULE_DEVICE_TABLE(of, snd_rpi_boomberry_dac_of_match);
  514. -
  515. -static struct platform_driver snd_rpi_boomberry_dac_driver = {
  516. - .driver = {
  517. - .name = "snd-rpi-boomberry-dac",
  518. - .owner = THIS_MODULE,
  519. - .of_match_table = snd_rpi_boomberry_dac_of_match,
  520. - },
  521. - .probe = snd_rpi_boomberry_dac_probe,
  522. - .remove = snd_rpi_boomberry_dac_remove,
  523. -};
  524. -
  525. -module_platform_driver(snd_rpi_boomberry_dac_driver);
  526. -
  527. -MODULE_AUTHOR("Milan Neskovic <info@boomberry.co>");
  528. -MODULE_DESCRIPTION("ASoC Driver for BoomBerry PI DAC HAT Sound Card");
  529. -MODULE_LICENSE("GPL v2");
  530. --- a/sound/soc/bcm/boomberry-digi.c
  531. +++ /dev/null
  532. @@ -1,215 +0,0 @@
  533. -/*
  534. - * ASoC Driver for BoomBerry Raspberry Pi Digi HAT Sound Card
  535. - *
  536. - * Author: Milan Neskovic
  537. - * Copyright 2016
  538. - * based on code by Daniel Matuschek <info@crazy-audio.com>
  539. - * based on code by Florian Meier <florian.meier@koalo.de>
  540. - *
  541. - * This program is free software; you can redistribute it and/or
  542. - * modify it under the terms of the GNU General Public License
  543. - * version 2 as published by the Free Software Foundation.
  544. - *
  545. - * This program is distributed in the hope that it will be useful, but
  546. - * WITHOUT ANY WARRANTY; without even the implied warranty of
  547. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  548. - * General Public License for more details.
  549. - */
  550. -
  551. -#include <linux/module.h>
  552. -#include <linux/platform_device.h>
  553. -
  554. -#include <sound/core.h>
  555. -#include <sound/pcm.h>
  556. -#include <sound/pcm_params.h>
  557. -#include <sound/soc.h>
  558. -#include <sound/jack.h>
  559. -
  560. -#include "../codecs/wm8804.h"
  561. -
  562. -static int snd_rpi_boomberry_digi_init(struct snd_soc_pcm_runtime *rtd)
  563. -{
  564. - struct snd_soc_codec *codec = rtd->codec;
  565. -
  566. - /* enable TX output */
  567. - snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x0);
  568. -
  569. - return 0;
  570. -}
  571. -
  572. -static int snd_rpi_boomberry_digi_startup(struct snd_pcm_substream *substream) {
  573. - /* turn on digital output */
  574. - struct snd_soc_pcm_runtime *rtd = substream->private_data;
  575. - struct snd_soc_codec *codec = rtd->codec;
  576. - snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x00);
  577. - return 0;
  578. -}
  579. -
  580. -static void snd_rpi_boomberry_digi_shutdown(struct snd_pcm_substream *substream) {
  581. - /* turn off output */
  582. - struct snd_soc_pcm_runtime *rtd = substream->private_data;
  583. - struct snd_soc_codec *codec = rtd->codec;
  584. - snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x3c);
  585. -}
  586. -
  587. -static int snd_rpi_boomberry_digi_hw_params(struct snd_pcm_substream *substream,
  588. - struct snd_pcm_hw_params *params)
  589. -{
  590. - struct snd_soc_pcm_runtime *rtd = substream->private_data;
  591. - struct snd_soc_dai *codec_dai = rtd->codec_dai;
  592. - struct snd_soc_codec *codec = rtd->codec;
  593. - struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  594. -
  595. - int sysclk = 27000000; /* This is fixed on this board */
  596. -
  597. - long mclk_freq=0;
  598. - int mclk_div=1;
  599. - int sampling_freq=1;
  600. -
  601. - int ret;
  602. -
  603. - int samplerate = params_rate(params);
  604. -
  605. - if (samplerate<=96000) {
  606. - mclk_freq=samplerate*256;
  607. - mclk_div=WM8804_MCLKDIV_256FS;
  608. - } else {
  609. - mclk_freq=samplerate*128;
  610. - mclk_div=WM8804_MCLKDIV_128FS;
  611. - }
  612. -
  613. - switch (samplerate) {
  614. - case 32000:
  615. - sampling_freq=0x03;
  616. - break;
  617. - case 44100:
  618. - sampling_freq=0x00;
  619. - break;
  620. - case 48000:
  621. - sampling_freq=0x02;
  622. - break;
  623. - case 88200:
  624. - sampling_freq=0x08;
  625. - break;
  626. - case 96000:
  627. - sampling_freq=0x0a;
  628. - break;
  629. - case 176400:
  630. - sampling_freq=0x0c;
  631. - break;
  632. - case 192000:
  633. - sampling_freq=0x0e;
  634. - break;
  635. - default:
  636. - dev_err(codec->dev,
  637. - "Failed to set WM8804 SYSCLK, unsupported samplerate %d\n",
  638. - samplerate);
  639. - }
  640. -
  641. - snd_soc_dai_set_clkdiv(codec_dai, WM8804_MCLK_DIV, mclk_div);
  642. - snd_soc_dai_set_pll(codec_dai, 0, 0, sysclk, mclk_freq);
  643. -
  644. - ret = snd_soc_dai_set_sysclk(codec_dai, WM8804_TX_CLKSRC_PLL,
  645. - sysclk, SND_SOC_CLOCK_OUT);
  646. - if (ret < 0) {
  647. - dev_err(codec->dev,
  648. - "Failed to set WM8804 SYSCLK: %d\n", ret);
  649. - return ret;
  650. - }
  651. -
  652. - /* Enable TX output */
  653. - snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x0);
  654. -
  655. - /* Power on */
  656. - snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0);
  657. -
  658. - /* set sampling frequency status bits */
  659. - snd_soc_update_bits(codec, WM8804_SPDTX4, 0x0f, sampling_freq);
  660. -
  661. - return snd_soc_dai_set_bclk_ratio(cpu_dai,64);
  662. -}
  663. -
  664. -/* machine stream operations */
  665. -static struct snd_soc_ops snd_rpi_boomberry_digi_ops = {
  666. - .hw_params = snd_rpi_boomberry_digi_hw_params,
  667. - .startup = snd_rpi_boomberry_digi_startup,
  668. - .shutdown = snd_rpi_boomberry_digi_shutdown,
  669. -};
  670. -
  671. -static struct snd_soc_dai_link snd_rpi_boomberry_digi_dai[] = {
  672. -{
  673. - .name = "BoomBerry Digi",
  674. - .stream_name = "BoomBerry Digi HiFi",
  675. - .cpu_dai_name = "bcm2708-i2s.0",
  676. - .codec_dai_name = "wm8804-spdif",
  677. - .platform_name = "bcm2708-i2s.0",
  678. - .codec_name = "wm8804.1-003b",
  679. - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  680. - SND_SOC_DAIFMT_CBM_CFM,
  681. - .ops = &snd_rpi_boomberry_digi_ops,
  682. - .init = snd_rpi_boomberry_digi_init,
  683. -},
  684. -};
  685. -
  686. -/* audio machine driver */
  687. -static struct snd_soc_card snd_rpi_boomberry_digi = {
  688. - .name = "snd_rpi_boomberry_digi",
  689. - .owner = THIS_MODULE,
  690. - .dai_link = snd_rpi_boomberry_digi_dai,
  691. - .num_links = ARRAY_SIZE(snd_rpi_boomberry_digi_dai),
  692. -};
  693. -
  694. -static int snd_rpi_boomberry_digi_probe(struct platform_device *pdev)
  695. -{
  696. - int ret = 0;
  697. -
  698. - snd_rpi_boomberry_digi.dev = &pdev->dev;
  699. -
  700. - if (pdev->dev.of_node) {
  701. - struct device_node *i2s_node;
  702. - struct snd_soc_dai_link *dai = &snd_rpi_boomberry_digi_dai[0];
  703. - i2s_node = of_parse_phandle(pdev->dev.of_node,
  704. - "i2s-controller", 0);
  705. -
  706. - if (i2s_node) {
  707. - dai->cpu_dai_name = NULL;
  708. - dai->cpu_of_node = i2s_node;
  709. - dai->platform_name = NULL;
  710. - dai->platform_of_node = i2s_node;
  711. - }
  712. - }
  713. -
  714. - ret = snd_soc_register_card(&snd_rpi_boomberry_digi);
  715. - if (ret)
  716. - dev_err(&pdev->dev,
  717. - "snd_soc_register_card() failed: %d\n", ret);
  718. -
  719. - return ret;
  720. -}
  721. -
  722. -static int snd_rpi_boomberry_digi_remove(struct platform_device *pdev)
  723. -{
  724. - return snd_soc_unregister_card(&snd_rpi_boomberry_digi);
  725. -}
  726. -
  727. -static const struct of_device_id snd_rpi_boomberry_digi_of_match[] = {
  728. - { .compatible = "boomberry,boomberry-digi", },
  729. - {},
  730. -};
  731. -MODULE_DEVICE_TABLE(of, snd_rpi_boomberry_digi_of_match);
  732. -
  733. -static struct platform_driver snd_rpi_boomberry_digi_driver = {
  734. - .driver = {
  735. - .name = "snd-rpi-boomberry-digi",
  736. - .owner = THIS_MODULE,
  737. - .of_match_table = snd_rpi_boomberry_digi_of_match,
  738. - },
  739. - .probe = snd_rpi_boomberry_digi_probe,
  740. - .remove = snd_rpi_boomberry_digi_remove,
  741. -};
  742. -
  743. -module_platform_driver(snd_rpi_boomberry_digi_driver);
  744. -
  745. -MODULE_AUTHOR("Milan Neskovic <info@boomberry.co>");
  746. -MODULE_DESCRIPTION("ASoC Driver for BoomBerry PI Digi HAT Sound Card");
  747. -MODULE_LICENSE("GPL v2");
  748. --- /dev/null
  749. +++ b/sound/soc/bcm/justboom-dac.c
  750. @@ -0,0 +1,162 @@
  751. +/*
  752. + * ASoC Driver for JustBoom DAC Raspberry Pi HAT Sound Card
  753. + *
  754. + * Author: Milan Neskovic
  755. + * Copyright 2016
  756. + * based on code by Daniel Matuschek <info@crazy-audio.com>
  757. + * based on code by Florian Meier <florian.meier@koalo.de>
  758. + *
  759. + * This program is free software; you can redistribute it and/or
  760. + * modify it under the terms of the GNU General Public License
  761. + * version 2 as published by the Free Software Foundation.
  762. + *
  763. + * This program is distributed in the hope that it will be useful, but
  764. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  765. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  766. + * General Public License for more details.
  767. + */
  768. +
  769. +#include <linux/module.h>
  770. +#include <linux/platform_device.h>
  771. +
  772. +#include <sound/core.h>
  773. +#include <sound/pcm.h>
  774. +#include <sound/pcm_params.h>
  775. +#include <sound/soc.h>
  776. +#include <sound/jack.h>
  777. +
  778. +#include "../codecs/pcm512x.h"
  779. +
  780. +static bool digital_gain_0db_limit = true;
  781. +
  782. +static int snd_rpi_justboom_dac_init(struct snd_soc_pcm_runtime *rtd)
  783. +{
  784. + struct snd_soc_codec *codec = rtd->codec;
  785. + snd_soc_update_bits(codec, PCM512x_GPIO_EN, 0x08, 0x08);
  786. + snd_soc_update_bits(codec, PCM512x_GPIO_OUTPUT_4, 0xf, 0x02);
  787. + snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08,0x08);
  788. +
  789. + if (digital_gain_0db_limit)
  790. + {
  791. + int ret;
  792. + struct snd_soc_card *card = rtd->card;
  793. +
  794. + ret = snd_soc_limit_volume(card, "Digital Playback Volume", 207);
  795. + if (ret < 0)
  796. + dev_warn(card->dev, "Failed to set volume limit: %d\n", ret);
  797. + }
  798. +
  799. + return 0;
  800. +}
  801. +
  802. +static int snd_rpi_justboom_dac_hw_params(struct snd_pcm_substream *substream,
  803. + struct snd_pcm_hw_params *params)
  804. +{
  805. + struct snd_soc_pcm_runtime *rtd = substream->private_data;
  806. + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  807. + /*return snd_soc_dai_set_bclk_ratio(cpu_dai, 64);*/
  808. + unsigned int sample_bits =
  809. + snd_pcm_format_physical_width(params_format(params));
  810. + return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2);
  811. +}
  812. +
  813. +static int snd_rpi_justboom_dac_startup(struct snd_pcm_substream *substream) {
  814. + struct snd_soc_pcm_runtime *rtd = substream->private_data;
  815. + struct snd_soc_codec *codec = rtd->codec;
  816. + snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08,0x08);
  817. + return 0;
  818. +}
  819. +
  820. +static void snd_rpi_justboom_dac_shutdown(struct snd_pcm_substream *substream) {
  821. + struct snd_soc_pcm_runtime *rtd = substream->private_data;
  822. + struct snd_soc_codec *codec = rtd->codec;
  823. + snd_soc_update_bits(codec, PCM512x_GPIO_CONTROL_1, 0x08,0x00);
  824. +}
  825. +
  826. +/* machine stream operations */
  827. +static struct snd_soc_ops snd_rpi_justboom_dac_ops = {
  828. + .hw_params = snd_rpi_justboom_dac_hw_params,
  829. + .startup = snd_rpi_justboom_dac_startup,
  830. + .shutdown = snd_rpi_justboom_dac_shutdown,
  831. +};
  832. +
  833. +static struct snd_soc_dai_link snd_rpi_justboom_dac_dai[] = {
  834. +{
  835. + .name = "JustBoom DAC",
  836. + .stream_name = "JustBoom DAC HiFi",
  837. + .cpu_dai_name = "bcm2708-i2s.0",
  838. + .codec_dai_name = "pcm512x-hifi",
  839. + .platform_name = "bcm2708-i2s.0",
  840. + .codec_name = "pcm512x.1-004d",
  841. + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  842. + SND_SOC_DAIFMT_CBS_CFS,
  843. + .ops = &snd_rpi_justboom_dac_ops,
  844. + .init = snd_rpi_justboom_dac_init,
  845. +},
  846. +};
  847. +
  848. +/* audio machine driver */
  849. +static struct snd_soc_card snd_rpi_justboom_dac = {
  850. + .name = "snd_rpi_justboom_dac",
  851. + .owner = THIS_MODULE,
  852. + .dai_link = snd_rpi_justboom_dac_dai,
  853. + .num_links = ARRAY_SIZE(snd_rpi_justboom_dac_dai),
  854. +};
  855. +
  856. +static int snd_rpi_justboom_dac_probe(struct platform_device *pdev)
  857. +{
  858. + int ret = 0;
  859. +
  860. + snd_rpi_justboom_dac.dev = &pdev->dev;
  861. +
  862. + if (pdev->dev.of_node) {
  863. + struct device_node *i2s_node;
  864. + struct snd_soc_dai_link *dai = &snd_rpi_justboom_dac_dai[0];
  865. + i2s_node = of_parse_phandle(pdev->dev.of_node,
  866. + "i2s-controller", 0);
  867. +
  868. + if (i2s_node) {
  869. + dai->cpu_dai_name = NULL;
  870. + dai->cpu_of_node = i2s_node;
  871. + dai->platform_name = NULL;
  872. + dai->platform_of_node = i2s_node;
  873. + }
  874. +
  875. + digital_gain_0db_limit = !of_property_read_bool(
  876. + pdev->dev.of_node, "justboom,24db_digital_gain");
  877. + }
  878. +
  879. + ret = snd_soc_register_card(&snd_rpi_justboom_dac);
  880. + if (ret)
  881. + dev_err(&pdev->dev,
  882. + "snd_soc_register_card() failed: %d\n", ret);
  883. +
  884. + return ret;
  885. +}
  886. +
  887. +static int snd_rpi_justboom_dac_remove(struct platform_device *pdev)
  888. +{
  889. + return snd_soc_unregister_card(&snd_rpi_justboom_dac);
  890. +}
  891. +
  892. +static const struct of_device_id snd_rpi_justboom_dac_of_match[] = {
  893. + { .compatible = "justboom,justboom-dac", },
  894. + {},
  895. +};
  896. +MODULE_DEVICE_TABLE(of, snd_rpi_justboom_dac_of_match);
  897. +
  898. +static struct platform_driver snd_rpi_justboom_dac_driver = {
  899. + .driver = {
  900. + .name = "snd-rpi-justboom-dac",
  901. + .owner = THIS_MODULE,
  902. + .of_match_table = snd_rpi_justboom_dac_of_match,
  903. + },
  904. + .probe = snd_rpi_justboom_dac_probe,
  905. + .remove = snd_rpi_justboom_dac_remove,
  906. +};
  907. +
  908. +module_platform_driver(snd_rpi_justboom_dac_driver);
  909. +
  910. +MODULE_AUTHOR("Milan Neskovic <info@justboom.co>");
  911. +MODULE_DESCRIPTION("ASoC Driver for JustBoom PI DAC HAT Sound Card");
  912. +MODULE_LICENSE("GPL v2");
  913. --- /dev/null
  914. +++ b/sound/soc/bcm/justboom-digi.c
  915. @@ -0,0 +1,215 @@
  916. +/*
  917. + * ASoC Driver for JustBoom Raspberry Pi Digi HAT Sound Card
  918. + *
  919. + * Author: Milan Neskovic
  920. + * Copyright 2016
  921. + * based on code by Daniel Matuschek <info@crazy-audio.com>
  922. + * based on code by Florian Meier <florian.meier@koalo.de>
  923. + *
  924. + * This program is free software; you can redistribute it and/or
  925. + * modify it under the terms of the GNU General Public License
  926. + * version 2 as published by the Free Software Foundation.
  927. + *
  928. + * This program is distributed in the hope that it will be useful, but
  929. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  930. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  931. + * General Public License for more details.
  932. + */
  933. +
  934. +#include <linux/module.h>
  935. +#include <linux/platform_device.h>
  936. +
  937. +#include <sound/core.h>
  938. +#include <sound/pcm.h>
  939. +#include <sound/pcm_params.h>
  940. +#include <sound/soc.h>
  941. +#include <sound/jack.h>
  942. +
  943. +#include "../codecs/wm8804.h"
  944. +
  945. +static int snd_rpi_justboom_digi_init(struct snd_soc_pcm_runtime *rtd)
  946. +{
  947. + struct snd_soc_codec *codec = rtd->codec;
  948. +
  949. + /* enable TX output */
  950. + snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x0);
  951. +
  952. + return 0;
  953. +}
  954. +
  955. +static int snd_rpi_justboom_digi_startup(struct snd_pcm_substream *substream) {
  956. + /* turn on digital output */
  957. + struct snd_soc_pcm_runtime *rtd = substream->private_data;
  958. + struct snd_soc_codec *codec = rtd->codec;
  959. + snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x00);
  960. + return 0;
  961. +}
  962. +
  963. +static void snd_rpi_justboom_digi_shutdown(struct snd_pcm_substream *substream) {
  964. + /* turn off output */
  965. + struct snd_soc_pcm_runtime *rtd = substream->private_data;
  966. + struct snd_soc_codec *codec = rtd->codec;
  967. + snd_soc_update_bits(codec, WM8804_PWRDN, 0x3c, 0x3c);
  968. +}
  969. +
  970. +static int snd_rpi_justboom_digi_hw_params(struct snd_pcm_substream *substream,
  971. + struct snd_pcm_hw_params *params)
  972. +{
  973. + struct snd_soc_pcm_runtime *rtd = substream->private_data;
  974. + struct snd_soc_dai *codec_dai = rtd->codec_dai;
  975. + struct snd_soc_codec *codec = rtd->codec;
  976. + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
  977. +
  978. + int sysclk = 27000000; /* This is fixed on this board */
  979. +
  980. + long mclk_freq=0;
  981. + int mclk_div=1;
  982. + int sampling_freq=1;
  983. +
  984. + int ret;
  985. +
  986. + int samplerate = params_rate(params);
  987. +
  988. + if (samplerate<=96000) {
  989. + mclk_freq=samplerate*256;
  990. + mclk_div=WM8804_MCLKDIV_256FS;
  991. + } else {
  992. + mclk_freq=samplerate*128;
  993. + mclk_div=WM8804_MCLKDIV_128FS;
  994. + }
  995. +
  996. + switch (samplerate) {
  997. + case 32000:
  998. + sampling_freq=0x03;
  999. + break;
  1000. + case 44100:
  1001. + sampling_freq=0x00;
  1002. + break;
  1003. + case 48000:
  1004. + sampling_freq=0x02;
  1005. + break;
  1006. + case 88200:
  1007. + sampling_freq=0x08;
  1008. + break;
  1009. + case 96000:
  1010. + sampling_freq=0x0a;
  1011. + break;
  1012. + case 176400:
  1013. + sampling_freq=0x0c;
  1014. + break;
  1015. + case 192000:
  1016. + sampling_freq=0x0e;
  1017. + break;
  1018. + default:
  1019. + dev_err(codec->dev,
  1020. + "Failed to set WM8804 SYSCLK, unsupported samplerate %d\n",
  1021. + samplerate);
  1022. + }
  1023. +
  1024. + snd_soc_dai_set_clkdiv(codec_dai, WM8804_MCLK_DIV, mclk_div);
  1025. + snd_soc_dai_set_pll(codec_dai, 0, 0, sysclk, mclk_freq);
  1026. +
  1027. + ret = snd_soc_dai_set_sysclk(codec_dai, WM8804_TX_CLKSRC_PLL,
  1028. + sysclk, SND_SOC_CLOCK_OUT);
  1029. + if (ret < 0) {
  1030. + dev_err(codec->dev,
  1031. + "Failed to set WM8804 SYSCLK: %d\n", ret);
  1032. + return ret;
  1033. + }
  1034. +
  1035. + /* Enable TX output */
  1036. + snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x0);
  1037. +
  1038. + /* Power on */
  1039. + snd_soc_update_bits(codec, WM8804_PWRDN, 0x9, 0);
  1040. +
  1041. + /* set sampling frequency status bits */
  1042. + snd_soc_update_bits(codec, WM8804_SPDTX4, 0x0f, sampling_freq);
  1043. +
  1044. + return snd_soc_dai_set_bclk_ratio(cpu_dai,64);
  1045. +}
  1046. +
  1047. +/* machine stream operations */
  1048. +static struct snd_soc_ops snd_rpi_justboom_digi_ops = {
  1049. + .hw_params = snd_rpi_justboom_digi_hw_params,
  1050. + .startup = snd_rpi_justboom_digi_startup,
  1051. + .shutdown = snd_rpi_justboom_digi_shutdown,
  1052. +};
  1053. +
  1054. +static struct snd_soc_dai_link snd_rpi_justboom_digi_dai[] = {
  1055. +{
  1056. + .name = "JustBoom Digi",
  1057. + .stream_name = "JustBoom Digi HiFi",
  1058. + .cpu_dai_name = "bcm2708-i2s.0",
  1059. + .codec_dai_name = "wm8804-spdif",
  1060. + .platform_name = "bcm2708-i2s.0",
  1061. + .codec_name = "wm8804.1-003b",
  1062. + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
  1063. + SND_SOC_DAIFMT_CBM_CFM,
  1064. + .ops = &snd_rpi_justboom_digi_ops,
  1065. + .init = snd_rpi_justboom_digi_init,
  1066. +},
  1067. +};
  1068. +
  1069. +/* audio machine driver */
  1070. +static struct snd_soc_card snd_rpi_justboom_digi = {
  1071. + .name = "snd_rpi_justboom_digi",
  1072. + .owner = THIS_MODULE,
  1073. + .dai_link = snd_rpi_justboom_digi_dai,
  1074. + .num_links = ARRAY_SIZE(snd_rpi_justboom_digi_dai),
  1075. +};
  1076. +
  1077. +static int snd_rpi_justboom_digi_probe(struct platform_device *pdev)
  1078. +{
  1079. + int ret = 0;
  1080. +
  1081. + snd_rpi_justboom_digi.dev = &pdev->dev;
  1082. +
  1083. + if (pdev->dev.of_node) {
  1084. + struct device_node *i2s_node;
  1085. + struct snd_soc_dai_link *dai = &snd_rpi_justboom_digi_dai[0];
  1086. + i2s_node = of_parse_phandle(pdev->dev.of_node,
  1087. + "i2s-controller", 0);
  1088. +
  1089. + if (i2s_node) {
  1090. + dai->cpu_dai_name = NULL;
  1091. + dai->cpu_of_node = i2s_node;
  1092. + dai->platform_name = NULL;
  1093. + dai->platform_of_node = i2s_node;
  1094. + }
  1095. + }
  1096. +
  1097. + ret = snd_soc_register_card(&snd_rpi_justboom_digi);
  1098. + if (ret)
  1099. + dev_err(&pdev->dev,
  1100. + "snd_soc_register_card() failed: %d\n", ret);
  1101. +
  1102. + return ret;
  1103. +}
  1104. +
  1105. +static int snd_rpi_justboom_digi_remove(struct platform_device *pdev)
  1106. +{
  1107. + return snd_soc_unregister_card(&snd_rpi_justboom_digi);
  1108. +}
  1109. +
  1110. +static const struct of_device_id snd_rpi_justboom_digi_of_match[] = {
  1111. + { .compatible = "justboom,justboom-digi", },
  1112. + {},
  1113. +};
  1114. +MODULE_DEVICE_TABLE(of, snd_rpi_justboom_digi_of_match);
  1115. +
  1116. +static struct platform_driver snd_rpi_justboom_digi_driver = {
  1117. + .driver = {
  1118. + .name = "snd-rpi-justboom-digi",
  1119. + .owner = THIS_MODULE,
  1120. + .of_match_table = snd_rpi_justboom_digi_of_match,
  1121. + },
  1122. + .probe = snd_rpi_justboom_digi_probe,
  1123. + .remove = snd_rpi_justboom_digi_remove,
  1124. +};
  1125. +
  1126. +module_platform_driver(snd_rpi_justboom_digi_driver);
  1127. +
  1128. +MODULE_AUTHOR("Milan Neskovic <info@justboom.co>");
  1129. +MODULE_DESCRIPTION("ASoC Driver for JustBoom PI Digi HAT Sound Card");
  1130. +MODULE_LICENSE("GPL v2");