Skip to contentSkip to conversation

USB Audio Gadget refactoring

PATCH In review Ruslan Bilovol 2 participants 6 messages Jun 18, 2017 – Jun 25, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v5 cover USB Audio Gadget refactoring

Hi Felipe,

This is v5 of audio gadget refactoring.
Note, that legacy f_uac1 function is broken since v4.10 by commit 7e4da3fcf7c9 ("usb: gadget: composite: Test get_alt() presence instead of set_alt()"). The fact that at v4.12-rc5 time nobody cares about may be a good sign that number of users is small if any. Thus making it legacy makes sence.

This series depends on legacy f_uac1 fix I posted before:
http://www.spinics.net/lists/linux-usb/msg158373.html
Without this fix it's not possible to check that refactoring didn't break legacy f_uac1 functionality

========================================

I came to this patch series when wanted to do two things:
- use UAC1 as virtual ALSA sound card on gadget side, just like UAC2 is used so it's possible to do rate resampling
- have both playback/capture support in UAC1

Since I wanted to have same behavior for both UAC1/UAC2, obviously I've got an utility part (u_audio.c) for virtual ALSA sound card handling like we have for ethernet(u_ether) or serial(u_serial) functions. Function-specific parts (f_uac1/f_uac2) became almost as storage for class-specific USB descriptors, some boilerplate for configfs, binding and few USB config request handling.

Originally in RFC [1] I've posted before, there was major change to f_uac1 after that it couldn't do direct play to existing ALSA sound card anymore, representing audio on gadget side as virtual ALSA sound card where audio streams are simply sinked to and sourced from it, so it may break current usecase for some people (and that's why it was RFC).

During RFC discussion, it was agreed to not touch existing f_uac1 implementation and create new one instead. At v4 patchet discussion another approach was agreed - current f_uac1.c gets renamed to f_uac1_legacy.c and introduced a *new* f_uac1.c instead that is done in current patchset (v5)

Now, it's possible to use existing user-space applications for audio routing between Audio Gadget and real sound card. I personally use alsaloop tool from alsautils and have ability to create PCM loopback between two different ALSA cards using rate resampling, which was not possible with previous "direct play to ALSA card" approach in f_uac1.

While here, also dropped redundant platform driver/device creation in f_uac2 driver (as well as didn't add "never implemented" volume/mute functionality in f_uac1_legacy to f_uac1) that made this work even easier to do.

This series is tested with both legacy g_audio.ko and modern configfs approaches under Ubuntu 14.04 (UAC1 and UAC2) and under Windows7 x64 (UAC1 only) having perfect results in all cases.

Comments, testing are welcome.

v5 changes:
- after discussion with Felipe, switched to another approach with making current f_uac1 legacy and introducing a new f_uac1.c instead
- addressed Jassi's copyright comments

v4 changes:
- renamed f_uac1_newapi to f_uac1_acard that is more meaningful
- rebased on top of balbi/next

v3 changes:
- renamed u_audio exported symbols so they don't conflict with old f_uac1 if both are built-in.

v2 changes:
- do not touch f_uac1, instead created f_uac1_newapi
- added documentation for f_uac1_newapi
- rebased on top of v4.8-rc1

[1] https://lkml.org/lkml/2016/5/23/649

Ruslan Bilovol (4):
usb: gadget: f_uac2: remove platform driver/device creation
usb: gadget: f_uac2: split out audio core
usb: gadget: function: make current f_uac1 implementation legacy
usb: gadget: add f_uac1 variant based on a new u_audio api

 Documentation/ABI/testing/configfs-usb-gadget-uac1 |   18 +-
 .../ABI/testing/configfs-usb-gadget-uac1_legacy    |   12 +
 Documentation/usb/gadget-testing.txt               |   53 +-
 drivers/usb/gadget/Kconfig                         |   29 +-
 drivers/usb/gadget/function/Makefile               |    5 +-
 drivers/usb/gadget/function/f_uac1.c               |  906 +++++++----------
 drivers/usb/gadget/function/f_uac1_legacy.c        | 1021 ++++++++++++++++++++
 drivers/usb/gadget/function/f_uac2.c               |  795 ++-------------
 drivers/usb/gadget/function/u_audio.c              |  662 +++++++++++++
 drivers/usb/gadget/function/u_audio.h              |   95 ++
 drivers/usb/gadget/function/u_uac1.h               |   87 +-
 .../gadget/function/{u_uac1.c => u_uac1_legacy.c}  |    7 +-
 drivers/usb/gadget/function/u_uac1_legacy.h        |   82 ++
 drivers/usb/gadget/legacy/Kconfig                  |   15 +-
 drivers/usb/gadget/legacy/audio.c                  |   55 +-
 15 files changed, 2494 insertions(+), 1348 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy
 create mode 100644 drivers/usb/gadget/function/f_uac1_legacy.c
 create mode 100644 drivers/usb/gadget/function/u_audio.c
 create mode 100644 drivers/usb/gadget/function/u_audio.h
 rename drivers/usb/gadget/function/{u_uac1.c => u_uac1_legacy.c} (98%)
 create mode 100644 drivers/usb/gadget/function/u_uac1_legacy.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v5 1/4 usb: gadget: f_uac2: remove platform driver/device creation

Simplify f_uac2 by removing platform driver/device creation; use composite's usb_gadget device as parent for sound card and for debug prints. This removes extra layer of code without any functional change.

---
 drivers/usb/gadget/function/f_uac2.c | 107 +++++++++--------------------------
 1 file changed, 28 insertions(+), 79 deletions(-)
drivers/usb/gadget/function/f_uac2.c +28 -79
index 5a7ba05..f674bae 100644
@@ -13,7 +13,6 @@
 
 #include <linux/usb/audio.h>
 #include <linux/usb/audio-v2.h>
-#include <linux/platform_device.h>
 #include <linux/module.h>
 
 #include <sound/core.h>
@@ -51,8 +50,6 @@
 #define UNFLW_CTRL	8
 #define OVFLW_CTRL	10
 
-static const char *uac2_name = "snd_uac2";
-
 struct uac2_req {
 	struct uac2_rtd_params *pp; /* parent param */
 	struct usb_request *req;
@@ -81,9 +78,6 @@ struct uac2_rtd_params {
 };
 
 struct snd_uac2_chip {
-	struct platform_device pdev;
-	struct platform_driver pdrv;
-
 	struct uac2_rtd_params p_prm;
 	struct uac2_rtd_params c_prm;
 
@@ -122,6 +116,7 @@ struct audio_dev {
 
 	struct usb_ep *in_ep, *out_ep;
 	struct usb_function func;
+	struct usb_gadget *gadget;
 
 	/* The ALSA Sound Card it represents on the USB-Client side */
 	struct snd_uac2_chip uac2;
@@ -140,12 +135,6 @@ struct audio_dev *uac2_to_agdev(struct snd_uac2_chip *u)
 }
 
 static inline
-struct snd_uac2_chip *pdev_to_uac2(struct platform_device *p)
-{
-	return container_of(p, struct snd_uac2_chip, pdev);
-}
-
-static inline
 struct f_uac2_opts *agdev_to_uac2_opts(struct audio_dev *agdev)
 {
 	return container_of(agdev->func.fi, struct f_uac2_opts, func_inst);
@@ -254,7 +243,7 @@ uint num_channels(uint chanmask)
 
 exit:
 	if (usb_ep_queue(ep, req, GFP_ATOMIC))
-		dev_err(&uac2->pdev.dev, "%d Error!\n", __LINE__);
+		dev_err(uac2->card->dev, "%d Error!\n", __LINE__);
 
 	if (update_alsa)
 		snd_pcm_period_elapsed(substream);
@@ -440,23 +429,22 @@ static int uac2_pcm_null(struct snd_pcm_substream *substream)
 	.prepare = uac2_pcm_null,
 };
 
-static int snd_uac2_probe(struct platform_device *pdev)
+static int snd_uac2_probe(struct audio_dev *audio_dev)
 {
-	struct snd_uac2_chip *uac2 = pdev_to_uac2(pdev);
+	struct snd_uac2_chip *uac2 = &audio_dev->uac2;
 	struct snd_card *card;
 	struct snd_pcm *pcm;
-	struct audio_dev *audio_dev;
 	struct f_uac2_opts *opts;
 	int err;
 	int p_chmask, c_chmask;
 
-	audio_dev = uac2_to_agdev(uac2);
 	opts = container_of(audio_dev->func.fi, struct f_uac2_opts, func_inst);
 	p_chmask = opts->p_chmask;
 	c_chmask = opts->c_chmask;
 
 	/* Choose any slot, with no id */
-	err = snd_card_new(&pdev->dev, -1, NULL, THIS_MODULE, 0, &card);
+	err = snd_card_new(&audio_dev->gadget->dev,
+			-1, NULL, THIS_MODULE, 0, &card);
 	if (err < 0)
 		return err;
 
@@ -481,16 +469,15 @@ static int snd_uac2_probe(struct platform_device *pdev)
 
 	strcpy(card->driver, "UAC2_Gadget");
 	strcpy(card->shortname, "UAC2_Gadget");
-	sprintf(card->longname, "UAC2_Gadget %i", pdev->id);
+	sprintf(card->longname, "UAC2_Gadget %i", card->dev->id);
 
 	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
 		snd_dma_continuous_data(GFP_KERNEL), 0, BUFF_SIZE_MAX);
 
 	err = snd_card_register(card);
-	if (!err) {
-		platform_set_drvdata(pdev, card);
+
+	if (!err)
 		return 0;
-	}
 
 snd_fail:
 	snd_card_free(card);
@@ -501,9 +488,9 @@ static int snd_uac2_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int snd_uac2_remove(struct platform_device *pdev)
+static int snd_uac2_remove(struct audio_dev *audio_dev)
 {
-	struct snd_card *card = platform_get_drvdata(pdev);
+	struct snd_card *card = audio_dev->uac2.card;
 
 	if (card)
 		return snd_card_free(card);
@@ -511,45 +498,6 @@ static int snd_uac2_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static void snd_uac2_release(struct device *dev)
-{
-	dev_dbg(dev, "releasing '%s'\n", dev_name(dev));
-}
-
-static int alsa_uac2_init(struct audio_dev *agdev)
-{
-	struct snd_uac2_chip *uac2 = &agdev->uac2;
-	int err;
-
-	uac2->pdrv.probe = snd_uac2_probe;
-	uac2->pdrv.remove = snd_uac2_remove;
-	uac2->pdrv.driver.name = uac2_name;
-
-	uac2->pdev.id = 0;
-	uac2->pdev.name = uac2_name;
-	uac2->pdev.dev.release = snd_uac2_release;
-
-	/* Register snd_uac2 driver */
-	err = platform_driver_register(&uac2->pdrv);
-	if (err)
-		return err;
-
-	/* Register snd_uac2 device */
-	err = platform_device_register(&uac2->pdev);
-	if (err)
-		platform_driver_unregister(&uac2->pdrv);
-
-	return err;
-}
-
-static void alsa_uac2_exit(struct audio_dev *agdev)
-{
-	struct snd_uac2_chip *uac2 = &agdev->uac2;
-
-	platform_driver_unregister(&uac2->pdrv);
-	platform_device_unregister(&uac2->pdev);
-}
-
 
 /* --------- USB Function Interface ------------- */
 
@@ -960,7 +908,7 @@ struct cntrl_range_lay3 {
 	}
 
 	if (usb_ep_disable(ep))
-		dev_err(&uac2->pdev.dev,
+		dev_err(uac2->card->dev,
 			"%s:%d Error!\n", __func__, __LINE__);
 }
 
@@ -994,7 +942,7 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 	struct snd_uac2_chip *uac2 = &agdev->uac2;
 	struct usb_composite_dev *cdev = cfg->cdev;
 	struct usb_gadget *gadget = cdev->gadget;
-	struct device *dev = &uac2->pdev.dev;
+	struct device *dev = &gadget->dev;
 	struct uac2_rtd_params *prm;
 	struct f_uac2_opts *uac2_opts;
 	struct usb_string *us;
@@ -1094,6 +1042,8 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 	if (ret)
 		return ret;
 
+	agdev->gadget = gadget;
+
 	prm = &agdev->uac2.c_prm;
 	prm->max_psize = hs_epout_desc.wMaxPacketSize;
 	prm->ureq = kcalloc(uac2_opts->req_number, sizeof(struct uac2_req),
@@ -1124,7 +1074,7 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 		goto err_no_memory;
 	}
 
-	ret = alsa_uac2_init(agdev);
+	ret = snd_uac2_probe(agdev);
 	if (ret)
 		goto err_no_memory;
 	return 0;
@@ -1136,6 +1086,7 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 	kfree(agdev->uac2.c_prm.rbuf);
 err_free_descs:
 	usb_free_all_descriptors(fn);
+	agdev->gadget = NULL;
 	return ret;
 }
 
@@ -1147,7 +1098,7 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 	struct f_uac2_opts *opts = agdev_to_uac2_opts(agdev);
 	struct snd_uac2_chip *uac2 = &agdev->uac2;
 	struct usb_gadget *gadget = cdev->gadget;
-	struct device *dev = &uac2->pdev.dev;
+	struct device *dev = &gadget->dev;
 	struct usb_request *req;
 	struct usb_ep *ep;
 	struct uac2_rtd_params *prm;
@@ -1247,7 +1198,6 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 afunc_get_alt(struct usb_function *fn, unsigned intf)
 {
 	struct audio_dev *agdev = func_to_agdev(fn);
-	struct snd_uac2_chip *uac2 = &agdev->uac2;
 
 	if (intf == agdev->ac_intf)
 		return agdev->ac_alt;
@@ -1256,7 +1206,7 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 	else if (intf == agdev->as_in_intf)
 		return agdev->as_in_alt;
 	else
-		dev_err(&uac2->pdev.dev,
+		dev_err(&agdev->gadget->dev,
 			"%s:%d Invalid Interface %d!\n",
 			__func__, __LINE__, intf);
 
@@ -1281,7 +1231,6 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 {
 	struct usb_request *req = fn->config->cdev->req;
 	struct audio_dev *agdev = func_to_agdev(fn);
-	struct snd_uac2_chip *uac2 = &agdev->uac2;
 	struct f_uac2_opts *opts;
 	u16 w_length = le16_to_cpu(cr->wLength);
 	u16 w_index = le16_to_cpu(cr->wIndex);
@@ -1310,7 +1259,7 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 		*(u8 *)req->buf = 1;
 		value = min_t(unsigned, w_length, 1);
 	} else {
-		dev_err(&uac2->pdev.dev,
+		dev_err(&agdev->gadget->dev,
 			"%s:%d control_selector=%d TODO!\n",
 			__func__, __LINE__, control_selector);
 	}
@@ -1323,7 +1272,6 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 {
 	struct usb_request *req = fn->config->cdev->req;
 	struct audio_dev *agdev = func_to_agdev(fn);
-	struct snd_uac2_chip *uac2 = &agdev->uac2;
 	struct f_uac2_opts *opts;
 	u16 w_length = le16_to_cpu(cr->wLength);
 	u16 w_index = le16_to_cpu(cr->wIndex);
@@ -1353,7 +1301,7 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 		value = min_t(unsigned, w_length, sizeof r);
 		memcpy(req->buf, &r, value);
 	} else {
-		dev_err(&uac2->pdev.dev,
+		dev_err(&agdev->gadget->dev,
 			"%s:%d control_selector=%d TODO!\n",
 			__func__, __LINE__, control_selector);
 	}
@@ -1389,12 +1337,11 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 setup_rq_inf(struct usb_function *fn, const struct usb_ctrlrequest *cr)
 {
 	struct audio_dev *agdev = func_to_agdev(fn);
-	struct snd_uac2_chip *uac2 = &agdev->uac2;
 	u16 w_index = le16_to_cpu(cr->wIndex);
 	u8 intf = w_index & 0xff;
 
 	if (intf != agdev->ac_intf) {
-		dev_err(&uac2->pdev.dev,
+		dev_err(&agdev->gadget->dev,
 			"%s:%d Error!\n", __func__, __LINE__);
 		return -EOPNOTSUPP;
 	}
@@ -1412,7 +1359,6 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 {
 	struct usb_composite_dev *cdev = fn->config->cdev;
 	struct audio_dev *agdev = func_to_agdev(fn);
-	struct snd_uac2_chip *uac2 = &agdev->uac2;
 	struct usb_request *req = cdev->req;
 	u16 w_length = le16_to_cpu(cr->wLength);
 	int value = -EOPNOTSUPP;
@@ -1424,14 +1370,15 @@ static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
 	if ((cr->bRequestType & USB_RECIP_MASK) == USB_RECIP_INTERFACE)
 		value = setup_rq_inf(fn, cr);
 	else
-		dev_err(&uac2->pdev.dev, "%s:%d Error!\n", __func__, __LINE__);
+		dev_err(&agdev->gadget->dev, "%s:%d Error!\n",
+				__func__, __LINE__);
 
 	if (value >= 0) {
 		req->length = value;
 		req->zero = value < w_length;
 		value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC);
 		if (value < 0) {
-			dev_err(&uac2->pdev.dev,
+			dev_err(&agdev->gadget->dev,
 				"%s:%d Error!\n", __func__, __LINE__);
 			req->status = 0;
 		}
@@ -1573,7 +1520,7 @@ static void afunc_unbind(struct usb_configuration *c, struct usb_function *f)
 	struct audio_dev *agdev = func_to_agdev(f);
 	struct uac2_rtd_params *prm;
 
-	alsa_uac2_exit(agdev);
+	snd_uac2_remove(agdev);
 
 	prm = &agdev->uac2.p_prm;
 	kfree(prm->rbuf);
@@ -1582,6 +1529,8 @@ static void afunc_unbind(struct usb_configuration *c, struct usb_function *f)
 	kfree(prm->rbuf);
 	kfree(prm->ureq);
 	usb_free_all_descriptors(f);
+
+	agdev->gadget = NULL;
 }
 
 static struct usb_function *afunc_alloc(struct usb_function_instance *fi)
Signature · 1 line
1.9.1
#2 lore raw

PATCH v5 2/4 usb: gadget: f_uac2: split out audio core

In reply to Ruslan Bilovol

Abstract the peripheral side ALSA sound card code from the f_uac2 function into a component that can be called by various functions, so the various flavors can be split apart and selectively reused.

Visible changes:
- add uac_params structure to pass audio paramteres for g_audio_setup
- make ALSA sound card's name configurable
- add [in/out]_ep_maxpsize
- allocate snd_uac_chip structure during g_audio_setup
- add u_audio_[start/stop]_[capture/playback] functions

---
 drivers/usb/gadget/Kconfig            |   4 +
 drivers/usb/gadget/function/Makefile  |   1 +
 drivers/usb/gadget/function/f_uac2.c  | 718 ++++------------------------------
 drivers/usb/gadget/function/u_audio.c | 662 +++++++++++++++++++++++++++++++
 drivers/usb/gadget/function/u_audio.h |  95 +++++
 drivers/usb/gadget/legacy/Kconfig     |   1 +
 6 files changed, 845 insertions(+), 636 deletions(-)
 create mode 100644 drivers/usb/gadget/function/u_audio.c
 create mode 100644 drivers/usb/gadget/function/u_audio.h
drivers/usb/gadget/Kconfig +4 -0
index b3c879b..3b0ffd6 100644
@@ -158,6 +158,9 @@ config USB_U_SERIAL
 config USB_U_ETHER
 	tristate
 
+config USB_U_AUDIO
+	tristate
+
 config USB_F_SERIAL
 	tristate
 
@@ -381,6 +384,7 @@ config USB_CONFIGFS_F_UAC2
 	depends on SND
 	select USB_LIBCOMPOSITE
 	select SND_PCM
+	select USB_U_AUDIO
 	select USB_F_UAC2
 	help
 	  This Audio function is compatible with USB Audio Class
drivers/usb/gadget/function/Makefile +1 -0
index cb8c225..b29f2ae 100644
@@ -32,6 +32,7 @@ usb_f_mass_storage-y		:= f_mass_storage.o storage_common.o
 obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
 usb_f_fs-y			:= f_fs.o
 obj-$(CONFIG_USB_F_FS)		+= usb_f_fs.o
+obj-$(CONFIG_USB_U_AUDIO)	+= u_audio.o
 usb_f_uac1-y			:= f_uac1.o u_uac1.o
 obj-$(CONFIG_USB_F_UAC1)	+= usb_f_uac1.o
 usb_f_uac2-y			:= f_uac2.o
drivers/usb/gadget/function/f_uac2.c +82 -636

897 lines not on this page · raw message

drivers/usb/gadget/function/u_audio.c new file +662 -0

662 lines not on this page · raw message

drivers/usb/gadget/function/u_audio.h new file +95 -0

95 lines not on this page · raw message

drivers/usb/gadget/legacy/Kconfig +1 -0
index 0b36878..5344064 100644
@@ -56,6 +56,7 @@ config USB_AUDIO
 	select SND_PCM
 	select USB_F_UAC1 if GADGET_UAC1
 	select USB_F_UAC2 if !GADGET_UAC1
+	select USB_U_AUDIO if USB_F_UAC2
 	help
 	  This Gadget Audio driver is compatible with USB Audio Class
 	  specification 2.0. It implements 1 AudioControl interface,
Signature · 1 line
1.9.1
#3 lore raw

PATCH v5 3/4 usb: gadget: function: make current f_uac1 implementation legacy

In reply to Ruslan Bilovol

Before introducing new f_uac1 function (with virtual ALSA card) make current implementation legacy.

This includes renaming of existing files, some
variables, config options and documentation

---
 ...gadget-uac1 => configfs-usb-gadget-uac1_legacy} |  2 +-
 Documentation/usb/gadget-testing.txt               |  9 +++--
 drivers/usb/gadget/Kconfig                         |  8 ++--
 drivers/usb/gadget/function/Makefile               |  4 +-
 .../gadget/function/{f_uac1.c => f_uac1_legacy.c}  | 45 +++++++++++-----------
 .../gadget/function/{u_uac1.c => u_uac1_legacy.c}  |  7 ++--
 .../gadget/function/{u_uac1.h => u_uac1_legacy.h}  |  8 ++--
 drivers/usb/gadget/legacy/Kconfig                  |  6 +--
 drivers/usb/gadget/legacy/audio.c                  | 26 ++++++-------
 9 files changed, 59 insertions(+), 56 deletions(-)
 rename Documentation/ABI/testing/{configfs-usb-gadget-uac1 => configfs-usb-gadget-uac1_legacy} (84%)
 rename drivers/usb/gadget/function/{f_uac1.c => f_uac1_legacy.c} (95%)
 rename drivers/usb/gadget/function/{u_uac1.c => u_uac1_legacy.c} (98%)
 rename drivers/usb/gadget/function/{u_uac1.h => u_uac1_legacy.h} (94%)
Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy renamed from Documentation/ABI/testing/configfs-usb-gadget-uac1 +1 -1
similarity index 84%
rename from Documentation/ABI/testing/configfs-usb-gadget-uac1
rename to Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy
index 8ba9a12..b2eaefd 100644
@@ -1,4 +1,4 @@
-What:		/config/usb-gadget/gadget/functions/uac1.name
+What:		/config/usb-gadget/gadget/functions/uac1_legacy.name
 Date:		Sep 2014
 KernelVersion:	3.18
 Description:
Documentation/usb/gadget-testing.txt +5 -4
index fb0cc4d..ce51d6e 100644
@@ -16,7 +16,7 @@ provided by gadgets.
 13. RNDIS function
 14. SERIAL function
 15. SOURCESINK function
-16. UAC1 function
+16. UAC1 function (legacy implementation)
 17. UAC2 function
 18. UVC function
 19. PRINTER function
@@ -589,15 +589,16 @@ device: run the gadget
 host: test-usb (tools/usb/testusb.c)
 
 
-16. UAC1 function
+16. UAC1 function (legacy implementation)
 =================
 
-The function is provided by usb_f_uac1.ko module.
+The function is provided by usb_f_uac1_legacy.ko module.
 
 Function-specific configfs interface
 ------------------------------------
 
-The function name to use when creating the function directory is "uac1".
+The function name to use when creating the function directory
+is "uac1_legacy".
 The uac1 function provides these attributes in its function directory:
 
 	audio_buf_size - audio buffer size
drivers/usb/gadget/Kconfig +4 -4
index 3b0ffd6..01c2e2b 100644
@@ -191,7 +191,7 @@ config USB_F_MASS_STORAGE
 config USB_F_FS
 	tristate
 
-config USB_F_UAC1
+config USB_F_UAC1_LEGACY
 	tristate
 
 config USB_F_UAC2
@@ -365,13 +365,13 @@ config USB_CONFIGFS_F_FS
 	  implemented in kernel space (for instance Ethernet, serial or
 	  mass storage) and other are implemented in user space.
 
-config USB_CONFIGFS_F_UAC1
-	bool "Audio Class 1.0"
+config USB_CONFIGFS_F_UAC1_LEGACY
+	bool "Audio Class 1.0 (legacy implementation)"
 	depends on USB_CONFIGFS
 	depends on SND
 	select USB_LIBCOMPOSITE
 	select SND_PCM
-	select USB_F_UAC1
+	select USB_F_UAC1_LEGACY
 	help
 	  This Audio function implements 1 AudioControl interface,
 	  1 AudioStreaming Interface each for USB-OUT and USB-IN.
drivers/usb/gadget/function/Makefile +2 -2
index b29f2ae..50ee517 100644
@@ -33,8 +33,8 @@ obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
 usb_f_fs-y			:= f_fs.o
 obj-$(CONFIG_USB_F_FS)		+= usb_f_fs.o
 obj-$(CONFIG_USB_U_AUDIO)	+= u_audio.o
-usb_f_uac1-y			:= f_uac1.o u_uac1.o
-obj-$(CONFIG_USB_F_UAC1)	+= usb_f_uac1.o
+usb_f_uac1_legacy-y		:= f_uac1_legacy.o u_uac1_legacy.o
+obj-$(CONFIG_USB_F_UAC1_LEGACY)	+= usb_f_uac1_legacy.o
 usb_f_uac2-y			:= f_uac2.o
 obj-$(CONFIG_USB_F_UAC2)	+= usb_f_uac2.o
 usb_f_uvc-y			:= f_uvc.o uvc_queue.o uvc_v4l2.o uvc_video.o uvc_configfs.o
drivers/usb/gadget/function/f_uac1_legacy.c renamed from drivers/usb/gadget/function/f_uac1.c +23 -22

152 lines not on this page · raw message

drivers/usb/gadget/function/u_uac1_legacy.c renamed from drivers/usb/gadget/function/u_uac1.c +4 -3
similarity index 98%
rename from drivers/usb/gadget/function/u_uac1.c
rename to drivers/usb/gadget/function/u_uac1_legacy.c
index c78c841..8aa76b4 100644
@@ -18,7 +18,7 @@
 #include <linux/random.h>
 #include <linux/syscalls.h>
 
-#include "u_uac1.h"
+#include "u_uac1_legacy.h"
 
 /*
  * This component encapsulates the ALSA devices for USB audio gadget
@@ -205,10 +205,11 @@ static int gaudio_open_snd_dev(struct gaudio *card)
 {
 	struct snd_pcm_file *pcm_file;
 	struct gaudio_snd_dev *snd;
-	struct f_uac1_opts *opts;
+	struct f_uac1_legacy_opts *opts;
 	char *fn_play, *fn_cap, *fn_cntl;
 
-	opts = container_of(card->func.fi, struct f_uac1_opts, func_inst);
+	opts = container_of(card->func.fi, struct f_uac1_legacy_opts,
+			    func_inst);
 	fn_play = opts->fn_play;
 	fn_cap = opts->fn_cap;
 	fn_cntl = opts->fn_cntl;
drivers/usb/gadget/function/u_uac1_legacy.h renamed from drivers/usb/gadget/function/u_uac1.h +4 -4
similarity index 94%
rename from drivers/usb/gadget/function/u_uac1.h
rename to drivers/usb/gadget/function/u_uac1_legacy.h
index 5c2ac8e..d715b1a 100644
@@ -9,8 +9,8 @@
  * Licensed under the GPL-2 or later.
  */
 
-#ifndef __U_AUDIO_H
-#define __U_AUDIO_H
+#ifndef __U_UAC1_LEGACY_H
+#define __U_UAC1_LEGACY_H
 
 #include <linux/device.h>
 #include <linux/err.h>
@@ -56,7 +56,7 @@ struct gaudio {
 	/* TODO */
 };
 
-struct f_uac1_opts {
+struct f_uac1_legacy_opts {
 	struct usb_function_instance	func_inst;
 	int				req_buf_size;
 	int				req_count;
@@ -79,4 +79,4 @@ struct f_uac1_opts {
 int u_audio_get_playback_channels(struct gaudio *card);
 int u_audio_get_playback_rate(struct gaudio *card);
 
-#endif /* __U_AUDIO_H */
+#endif /* __U_UAC1_LEGACY_H */
drivers/usb/gadget/legacy/Kconfig +3 -3
index 5344064..87bacb6 100644
@@ -54,8 +54,8 @@ config USB_AUDIO
 	depends on SND
 	select USB_LIBCOMPOSITE
 	select SND_PCM
-	select USB_F_UAC1 if GADGET_UAC1
-	select USB_F_UAC2 if !GADGET_UAC1
+	select USB_F_UAC1_LEGACY if GADGET_UAC1_LEGACY
+	select USB_F_UAC2 if !GADGET_UAC1_LEGACY
 	select USB_U_AUDIO if USB_F_UAC2
 	help
 	  This Gadget Audio driver is compatible with USB Audio Class
@@ -73,7 +73,7 @@ config USB_AUDIO
 	  Say "y" to link the driver statically, or "m" to build a
 	  dynamically linked module called "g_audio".
 
-config GADGET_UAC1
+config GADGET_UAC1_LEGACY
 	bool "UAC 1.0 (Legacy)"
 	depends on USB_AUDIO
 	help
drivers/usb/gadget/legacy/audio.c +13 -13
index 8a39f42..bf5592a 100644
@@ -20,7 +20,7 @@
 
 USB_GADGET_COMPOSITE_OPTIONS();
 
-#ifndef CONFIG_GADGET_UAC1
+#ifndef CONFIG_GADGET_UAC1_LEGACY
 #include "u_uac2.h"
 
 /* Playback(USB-IN) Default Stereo - Fl/Fr */
@@ -53,7 +53,7 @@
 module_param(c_ssize, uint, S_IRUGO);
 MODULE_PARM_DESC(c_ssize, "Capture Sample Size(bytes)");
 #else
-#include "u_uac1.h"
+#include "u_uac1_legacy.h"
 
 static char *fn_play = FILE_PCM_PLAYBACK;
 module_param(fn_play, charp, S_IRUGO);
@@ -99,7 +99,7 @@
 	NULL,
 };
 
-#ifndef CONFIG_GADGET_UAC1
+#ifndef CONFIG_GADGET_UAC1_LEGACY
 static struct usb_function_instance *fi_uac2;
 static struct usb_function *f_uac2;
 #else
@@ -125,7 +125,7 @@
 
 	/* .bcdUSB = DYNAMIC */
 
-#ifdef CONFIG_GADGET_UAC1
+#ifdef CONFIG_GADGET_UAC1_LEGACY
 	.bDeviceClass =		USB_CLASS_PER_INTERFACE,
 	.bDeviceSubClass =	0,
 	.bDeviceProtocol =	0,
@@ -164,7 +164,7 @@ static int audio_do_config(struct usb_configuration *c)
 		c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 	}
 
-#ifdef CONFIG_GADGET_UAC1
+#ifdef CONFIG_GADGET_UAC1_LEGACY
 	f_uac1 = usb_get_function(fi_uac1);
 	if (IS_ERR(f_uac1)) {
 		status = PTR_ERR(f_uac1);
@@ -204,24 +204,24 @@ static int audio_do_config(struct usb_configuration *c)
 
 static int audio_bind(struct usb_composite_dev *cdev)
 {
-#ifndef CONFIG_GADGET_UAC1
+#ifndef CONFIG_GADGET_UAC1_LEGACY
 	struct f_uac2_opts	*uac2_opts;
 #else
-	struct f_uac1_opts	*uac1_opts;
+	struct f_uac1_legacy_opts	*uac1_opts;
 #endif
 	int			status;
 
-#ifndef CONFIG_GADGET_UAC1
+#ifndef CONFIG_GADGET_UAC1_LEGACY
 	fi_uac2 = usb_get_function_instance("uac2");
 	if (IS_ERR(fi_uac2))
 		return PTR_ERR(fi_uac2);
 #else
-	fi_uac1 = usb_get_function_instance("uac1");
+	fi_uac1 = usb_get_function_instance("uac1_legacy");
 	if (IS_ERR(fi_uac1))
 		return PTR_ERR(fi_uac1);
 #endif
 
-#ifndef CONFIG_GADGET_UAC1
+#ifndef CONFIG_GADGET_UAC1_LEGACY
 	uac2_opts = container_of(fi_uac2, struct f_uac2_opts, func_inst);
 	uac2_opts->p_chmask = p_chmask;
 	uac2_opts->p_srate = p_srate;
@@ -231,7 +231,7 @@ static int audio_bind(struct usb_composite_dev *cdev)
 	uac2_opts->c_ssize = c_ssize;
 	uac2_opts->req_number = UAC2_DEF_REQ_NUM;
 #else
-	uac1_opts = container_of(fi_uac1, struct f_uac1_opts, func_inst);
+	uac1_opts = container_of(fi_uac1, struct f_uac1_legacy_opts, func_inst);
 	uac1_opts->fn_play = fn_play;
 	uac1_opts->fn_cap = fn_cap;
 	uac1_opts->fn_cntl = fn_cntl;
@@ -269,7 +269,7 @@ static int audio_bind(struct usb_composite_dev *cdev)
 	kfree(otg_desc[0]);
 	otg_desc[0] = NULL;
 fail:
-#ifndef CONFIG_GADGET_UAC1
+#ifndef CONFIG_GADGET_UAC1_LEGACY
 	usb_put_function_instance(fi_uac2);
 #else
 	usb_put_function_instance(fi_uac1);
@@ -279,7 +279,7 @@ static int audio_bind(struct usb_composite_dev *cdev)
 
 static int audio_unbind(struct usb_composite_dev *cdev)
 {
-#ifdef CONFIG_GADGET_UAC1
+#ifdef CONFIG_GADGET_UAC1_LEGACY
 	if (!IS_ERR_OR_NULL(f_uac1))
 		usb_put_function(f_uac1);
 	if (!IS_ERR_OR_NULL(fi_uac1))
Signature · 1 line
1.9.1
#4 lore raw

PATCH v5 4/4 usb: gadget: add f_uac1 variant based on a new u_audio api

In reply to Ruslan Bilovol

This patch adds a new function 'f_uac1' (f_uac1 with virtual "ALSA card") that uses recently created u_audio API. Comparing to legacy f_uac1 function implementation it doesn't require any real Audio codec to be present on the device. In f_uac1 audio streams are simply sinked to and sourced from a virtual ALSA sound card created using u_audio API.

Legacy f_uac1 approach is to write audio samples directly to existing ALSA sound card

f_uac1 approach is more generic/flexible one - create an ALSA sound card that represents USB Audio function and allows to be used by userspace application that may choose to do whatever it wants with the data received from the USB Host and choose to provide whatever it wants as audio data to the USB Host.

f_uac1 also has capture support (gadget->host) thanks to easy implementation via u_audio. By default, capture interface has 48000kHz/2ch configuration, same as playback channel has.

f_uac1 descriptors naming convention uses f_uac2 driver naming convention that makes it more common and meaningful.

Comparing to f_uac1_legacy, the f_uac1 doesn't have volume/mute functionality. This is because the f_uac1 volume/mute feature unit was dummy implementation since that driver creation (2009) and never had any real volume control or mute functionality, so there is no any difference here.

Since f_uac1 functionality, exposed interface to userspace (virtual ALSA card), input parameters are so different comparing to f_uac1_legacy, that there is no any reason to keep them in the same file/module, and separate function was created.

g_audio can be built using one of existing UAC functions (f_uac1, f_uac1_legacy or f_uac2)

---
 Documentation/ABI/testing/configfs-usb-gadget-uac1 |  14 +
 Documentation/usb/gadget-testing.txt               |  44 ++
 drivers/usb/gadget/Kconfig                         |  25 +-
 drivers/usb/gadget/function/Makefile               |   2 +
 drivers/usb/gadget/function/f_uac1.c               | 802 +++++++++++++++++++++
 drivers/usb/gadget/function/u_uac1.h               |  41 ++
 drivers/usb/gadget/legacy/Kconfig                  |  18 +-
 drivers/usb/gadget/legacy/audio.c                  |  69 +-
 8 files changed, 1000 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-uac1
 create mode 100644 drivers/usb/gadget/function/f_uac1.c
 create mode 100644 drivers/usb/gadget/function/u_uac1.h
Documentation/ABI/testing/configfs-usb-gadget-uac1 new file +14 -0
new file mode 100644
index 0000000..abfe447
@@ -0,0 +1,14 @@
+What:		/config/usb-gadget/gadget/functions/uac1.name
+Date:		June 2017
+KernelVersion:	4.14
+Description:
+		The attributes:
+
+		c_chmask - capture channel mask
+		c_srate - capture sampling rate
+		c_ssize - capture sample size (bytes)
+		p_chmask - playback channel mask
+		p_srate - playback sampling rate
+		p_ssize - playback sample size (bytes)
+		req_number - the number of pre-allocated request
+			for both capture and playback
Documentation/usb/gadget-testing.txt +44 -0

53 lines not on this page · raw message

drivers/usb/gadget/Kconfig +23 -2
index 01c2e2b..35cc641 100644
@@ -191,6 +191,9 @@ config USB_F_MASS_STORAGE
 config USB_F_FS
 	tristate
 
+config USB_F_UAC1
+	tristate
+
 config USB_F_UAC1_LEGACY
 	tristate
 
@@ -365,6 +368,24 @@ config USB_CONFIGFS_F_FS
 	  implemented in kernel space (for instance Ethernet, serial or
 	  mass storage) and other are implemented in user space.
 
+config USB_CONFIGFS_F_UAC1
+	bool "Audio Class 1.0"
+	depends on USB_CONFIGFS
+	depends on SND
+	select USB_LIBCOMPOSITE
+	select SND_PCM
+	select USB_U_AUDIO
+	select USB_F_UAC1
+	help
+	  This Audio function implements 1 AudioControl interface,
+	  1 AudioStreaming Interface each for USB-OUT and USB-IN.
+	  This driver doesn't expect any real Audio codec to be present
+	  on the device - the audio streams are simply sinked to and
+	  sourced from a virtual ALSA sound card created. The user-space
+	  application may choose to do whatever it wants with the data
+	  received from the USB Host and choose to provide whatever it
+	  wants as audio data to the USB Host.
+
 config USB_CONFIGFS_F_UAC1_LEGACY
 	bool "Audio Class 1.0 (legacy implementation)"
 	depends on USB_CONFIGFS
@@ -375,8 +396,8 @@ config USB_CONFIGFS_F_UAC1_LEGACY
 	help
 	  This Audio function implements 1 AudioControl interface,
 	  1 AudioStreaming Interface each for USB-OUT and USB-IN.
-	  This driver requires a real Audio codec to be present
-	  on the device.
+	  This is a legacy driver and requires a real Audio codec
+	  to be present on the device.
 
 config USB_CONFIGFS_F_UAC2
 	bool "Audio Class 2.0"
drivers/usb/gadget/function/Makefile +2 -0
index 50ee517..86e8252 100644
@@ -33,6 +33,8 @@ obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
 usb_f_fs-y			:= f_fs.o
 obj-$(CONFIG_USB_F_FS)		+= usb_f_fs.o
 obj-$(CONFIG_USB_U_AUDIO)	+= u_audio.o
+usb_f_uac1-y			:= f_uac1.o
+obj-$(CONFIG_USB_F_UAC1)	+= usb_f_uac1.o
 usb_f_uac1_legacy-y		:= f_uac1_legacy.o u_uac1_legacy.o
 obj-$(CONFIG_USB_F_UAC1_LEGACY)	+= usb_f_uac1_legacy.o
 usb_f_uac2-y			:= f_uac2.o
drivers/usb/gadget/function/f_uac1.c new file +802 -0

802 lines not on this page · raw message

drivers/usb/gadget/function/u_uac1.h new file +41 -0

41 lines not on this page · raw message

drivers/usb/gadget/legacy/Kconfig +13 -5
index 87bacb6..a12fb45 100644
@@ -54,9 +54,10 @@ config USB_AUDIO
 	depends on SND
 	select USB_LIBCOMPOSITE
 	select SND_PCM
-	select USB_F_UAC1_LEGACY if GADGET_UAC1_LEGACY
-	select USB_F_UAC2 if !GADGET_UAC1_LEGACY
-	select USB_U_AUDIO if USB_F_UAC2
+	select USB_F_UAC1 if (GADGET_UAC1 && !GADGET_UAC1_LEGACY)
+	select USB_F_UAC1_LEGACY if (GADGET_UAC1 && GADGET_UAC1_LEGACY)
+	select USB_F_UAC2 if !GADGET_UAC1
+	select USB_U_AUDIO if (USB_F_UAC2 || USB_F_UAC1)
 	help
 	  This Gadget Audio driver is compatible with USB Audio Class
 	  specification 2.0. It implements 1 AudioControl interface,
@@ -73,11 +74,18 @@ config USB_AUDIO
 	  Say "y" to link the driver statically, or "m" to build a
 	  dynamically linked module called "g_audio".
 
+config GADGET_UAC1
+	bool "UAC 1.0"
+	depends on USB_AUDIO
+	help
+	  If you instead want older USB Audio Class specification 1.0 support
+	  with similar driver capabilities.
+
 config GADGET_UAC1_LEGACY
 	bool "UAC 1.0 (Legacy)"
-	depends on USB_AUDIO
+	depends on GADGET_UAC1
 	help
-	  If you instead want older UAC Spec-1.0 driver that also has audio
+	  If you instead want legacy UAC Spec-1.0 driver that also has audio
 	  paths hardwired to the Audio codec chip on-board and doesn't work
 	  without one.
 
drivers/usb/gadget/legacy/audio.c +61 -8

144 lines not on this page · raw message

Signature · 1 line
1.9.1
Acked-by on the v5 series
#5 lore raw
In reply to Ruslan Bilovol
Quoted 111 lines · Ruslan Bilovol

Hi Felipe,

This is v5 of audio gadget refactoring.
Note, that legacy f_uac1 function is broken since v4.10 by commit 7e4da3fcf7c9 ("usb: gadget: composite: Test get_alt() presence instead of set_alt()"). The fact that at v4.12-rc5 time nobody cares about may be a good sign that number of users is small if any. Thus making it legacy makes sence.

This series depends on legacy f_uac1 fix I posted before:
http://www.spinics.net/lists/linux-usb/msg158373.html
Without this fix it's not possible to check that refactoring didn't break legacy f_uac1 functionality

========================================

I came to this patch series when wanted to do two things:
- use UAC1 as virtual ALSA sound card on gadget side, just like UAC2 is used so it's possible to do rate resampling
- have both playback/capture support in UAC1

Since I wanted to have same behavior for both UAC1/UAC2, obviously I've got an utility part (u_audio.c) for virtual ALSA sound card handling like we have for ethernet(u_ether) or serial(u_serial) functions. Function-specific parts (f_uac1/f_uac2) became almost as storage for class-specific USB descriptors, some boilerplate for configfs, binding and few USB config request handling.

Originally in RFC [1] I've posted before, there was major change to f_uac1 after that it couldn't do direct play to existing ALSA sound card anymore, representing audio on gadget side as virtual ALSA sound card where audio streams are simply sinked to and sourced from it, so it may break current usecase for some people (and that's why it was RFC).

During RFC discussion, it was agreed to not touch existing f_uac1 implementation and create new one instead. At v4 patchet discussion another approach was agreed - current f_uac1.c gets renamed to f_uac1_legacy.c and introduced a *new* f_uac1.c instead that is done in current patchset (v5)

Now, it's possible to use existing user-space applications for audio routing between Audio Gadget and real sound card. I personally use alsaloop tool from alsautils and have ability to create PCM loopback between two different ALSA cards using rate resampling, which was not possible with previous "direct play to ALSA card" approach in f_uac1.

While here, also dropped redundant platform driver/device creation in f_uac2 driver (as well as didn't add "never implemented" volume/mute functionality in f_uac1_legacy to f_uac1) that made this work even easier to do.

This series is tested with both legacy g_audio.ko and modern configfs approaches under Ubuntu 14.04 (UAC1 and UAC2) and under Windows7 x64 (UAC1 only) having perfect results in all cases.

Comments, testing are welcome.

v5 changes:
- after discussion with Felipe, switched to another approach with making current f_uac1 legacy and introducing a new f_uac1.c instead
- addressed Jassi's copyright comments

v4 changes:
- renamed f_uac1_newapi to f_uac1_acard that is more meaningful
- rebased on top of balbi/next

v3 changes:
- renamed u_audio exported symbols so they don't conflict with old f_uac1 if both are built-in.

v2 changes:
- do not touch f_uac1, instead created f_uac1_newapi
- added documentation for f_uac1_newapi
- rebased on top of v4.8-rc1

[1] https://lkml.org/lkml/2016/5/23/649

Ruslan Bilovol (4):
usb: gadget: f_uac2: remove platform driver/device creation
usb: gadget: f_uac2: split out audio core
usb: gadget: function: make current f_uac1 implementation legacy
usb: gadget: add f_uac1 variant based on a new u_audio api

 Documentation/ABI/testing/configfs-usb-gadget-uac1 |   18 +-
 .../ABI/testing/configfs-usb-gadget-uac1_legacy    |   12 +
 Documentation/usb/gadget-testing.txt               |   53 +-
 drivers/usb/gadget/Kconfig                         |   29 +-
 drivers/usb/gadget/function/Makefile               |    5 +-
 drivers/usb/gadget/function/f_uac1.c               |  906 +++++++----------
 drivers/usb/gadget/function/f_uac1_legacy.c        | 1021 ++++++++++++++++++++
 drivers/usb/gadget/function/f_uac2.c               |  795 ++-------------
 drivers/usb/gadget/function/u_audio.c              |  662 +++++++++++++
 drivers/usb/gadget/function/u_audio.h              |   95 ++
 drivers/usb/gadget/function/u_uac1.h               |   87 +-
 .../gadget/function/{u_uac1.c => u_uac1_legacy.c}  |    7 +-
 drivers/usb/gadget/function/u_uac1_legacy.h        |   82 ++
 drivers/usb/gadget/legacy/Kconfig                  |   15 +-
Quoted 9 lines
 drivers/usb/gadget/legacy/audio.c                  |   55 +-
 15 files changed, 2494 insertions(+), 1348 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy
 create mode 100644 drivers/usb/gadget/function/f_uac1_legacy.c
 create mode 100644 drivers/usb/gadget/function/u_audio.c
 create mode 100644 drivers/usb/gadget/function/u_audio.h
 rename drivers/usb/gadget/function/{u_uac1.c => u_uac1_legacy.c} (98%)
 create mode 100644 drivers/usb/gadget/function/u_uac1_legacy.h

Thanks.