From c84916368d9d55e090ebf39d595a257bac4c9758 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 29 Jan 2024 16:55:15 +0000 Subject: aosp/android-mainline: update series up to d23db69132acd ("ANDROID: revert out-of-tree Android USB gadget changes") Signed-off-by: Lee Jones Change-Id: Ic1a37f94effc7b288e226d3d7cd52d78e7026d0e --- ...t-sink-vbus-if-operational-current-is-0mA.patch | 45 - ...core-Introduce-macro-SOC_SINGLE_MULTI_EXT.patch | 103 -- .../NOUPSTREAM-ANDROID-gki_defconfigs.patch | 23 +- ...t-configfs-Add-Uevent-to-notify-userspace.patch | 424 ----- ..._accessory-Add-Android-Accessory-function.patch | 1877 -------------------- ...source-New-gadget-driver-for-audio-output.patch | 1150 ------------ ...ID-usb-gadget-f_midi-create-F_midi-device.patch | 117 -- ...t-sink-vbus-if-operational-current-is-0mA.patch | 49 + .../_____ANNOTATION-Android-exports_____.patch | 2 +- ...N-Android-kconfigs-and-build-scripts_____.patch | 2 +- ..._____ANNOTATION-Android-vendor-hooks_____.patch | 2 +- ...___ANNOTATION-Incremental-filesystem_____.patch | 2 +- .../_____ANNOTATION-UFS-driver-changes_____.patch | 4 +- .../_____ANNOTATION-USB-changes_____.patch | 20 - .../_____ANNOTATION-block-changes_____.patch | 2 +- ...____ANNOTATION-device-mapper-changes_____.patch | 2 +- .../_____ANNOTATION-filesystem-changes_____.patch | 2 +- .../_____ANNOTATION-graphics-changes_____.patch | 4 +- ...OTATION-hardware-wrapped-key-support_____.patch | 2 +- .../_____ANNOTATION-networking-changes_____.patch | 2 +- ...__ANNOTATION-remove-ANNOTATIONS-file_____.patch | 7 +- .../_____ANNOTATION-sound-changes_____.patch | 4 +- android-mainline/series | 12 +- 23 files changed, 77 insertions(+), 3780 deletions(-) delete mode 100644 android-mainline/ANDROID-Revert-usb-typec-tcpm-not-sink-vbus-if-operational-current-is-0mA.patch delete mode 100644 android-mainline/ANDROID-SoC-core-Introduce-macro-SOC_SINGLE_MULTI_EXT.patch delete mode 100644 android-mainline/NOUPSTREAM-ANDROID-usb-gadget-configfs-Add-Uevent-to-notify-userspace.patch delete mode 100644 android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_accessory-Add-Android-Accessory-function.patch delete mode 100644 android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_audio_source-New-gadget-driver-for-audio-output.patch delete mode 100644 android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_midi-create-F_midi-device.patch create mode 100644 android-mainline/TODO-LEE-ANDROID-Revert-usb-typec-tcpm-not-sink-vbus-if-operational-current-is-0mA.patch delete mode 100644 android-mainline/_____ANNOTATION-USB-changes_____.patch diff --git a/android-mainline/ANDROID-Revert-usb-typec-tcpm-not-sink-vbus-if-operational-current-is-0mA.patch b/android-mainline/ANDROID-Revert-usb-typec-tcpm-not-sink-vbus-if-operational-current-is-0mA.patch deleted file mode 100644 index f337e929..00000000 --- a/android-mainline/ANDROID-Revert-usb-typec-tcpm-not-sink-vbus-if-operational-current-is-0mA.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Andr=C3=A9=20Draszik?= -Date: Wed, 25 Oct 2023 14:26:51 +0100 -Subject: ANDROID: Revert "usb: typec: tcpm: not sink vbus if operational - current is 0mA" -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This reverts commit 803b1c8a0cea58cccde16eba31d285956f4c920c. - -Prevents Pixel from charging. Revert while we investigate the issue. - -Test: adb shell cat /sys/class/power_supply/battery/status -Bug: 307718635 -Change-Id: I9e8c6c62aac25cf41ac37c1d6bda696d8ecaf4aa -Signed-off-by: André Draszik ---- - drivers/usb/typec/tcpm/tcpm.c | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c ---- a/drivers/usb/typec/tcpm/tcpm.c -+++ b/drivers/usb/typec/tcpm/tcpm.c -@@ -4267,9 +4267,7 @@ static void run_state_machine(struct tcpm_port *port) - if (port->slow_charger_loop && (current_lim > PD_P_SNK_STDBY_MW / 5)) - current_lim = PD_P_SNK_STDBY_MW / 5; - tcpm_set_current_limit(port, current_lim, 5000); -- /* Not sink vbus if operational current is 0mA */ -- tcpm_set_charge(port, !!pdo_max_current(port->snk_pdo[0])); -- -+ tcpm_set_charge(port, true); - if (!port->pd_supported) - tcpm_set_state(port, SNK_READY, 0); - else -@@ -4552,8 +4550,7 @@ static void run_state_machine(struct tcpm_port *port) - tcpm_set_current_limit(port, - tcpm_get_current_limit(port), - 5000); -- /* Not sink vbus if operational current is 0mA */ -- tcpm_set_charge(port, !!pdo_max_current(port->snk_pdo[0])); -+ tcpm_set_charge(port, true); - } - if (port->ams == HARD_RESET) - tcpm_ams_finish(port); diff --git a/android-mainline/ANDROID-SoC-core-Introduce-macro-SOC_SINGLE_MULTI_EXT.patch b/android-mainline/ANDROID-SoC-core-Introduce-macro-SOC_SINGLE_MULTI_EXT.patch deleted file mode 100644 index 87b58445..00000000 --- a/android-mainline/ANDROID-SoC-core-Introduce-macro-SOC_SINGLE_MULTI_EXT.patch +++ /dev/null @@ -1,103 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Meng Wang -Date: Wed, 6 Sep 2017 10:21:14 +0800 -Subject: ANDROID: SoC: core: Introduce macro SOC_SINGLE_MULTI_EXT - -For some of the mixer controls, client would like to register -count as a parameter. Macro adds support to specify the count. - -[CPNOTE: 19/07/21] Lee: Requested status via the bug - -BUG: 144610828 -Change-Id: I26343af2e4a35952d93dc2d5fa0caad2a3e50ffe -Signed-off-by: Banajit Goswami -Signed-off-by: Sudheer Papothi -Signed-off-by: Meng Wang -Signed-off-by: Lee Jones ---- - include/sound/soc.h | 15 +++++++++++++++ - sound/soc/soc-core.c | 33 +++++++++++++++++++++++++++++++++ - 2 files changed, 48 insertions(+) - -diff --git a/include/sound/soc.h b/include/sound/soc.h ---- a/include/sound/soc.h -+++ b/include/sound/soc.h -@@ -253,6 +253,14 @@ - .get = xhandler_get, .put = xhandler_put, \ - .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \ - xmax, xinvert) } -+#define SOC_SINGLE_MULTI_EXT(xname, xreg, xshift, xmax, xinvert, xcount,\ -+ xhandler_get, xhandler_put) \ -+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ -+ .info = snd_soc_info_multi_ext, \ -+ .get = xhandler_get, .put = xhandler_put, \ -+ .private_value = (unsigned long)&(struct soc_multi_mixer_control) \ -+ {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \ -+ .count = xcount, .platform_max = xmax, .invert = xinvert} } - #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\ - xhandler_get, xhandler_put, tlv_array) \ - { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ -@@ -606,6 +614,8 @@ int snd_soc_get_strobe(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); - int snd_soc_put_strobe(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol); -+int snd_soc_info_multi_ext(struct snd_kcontrol *kcontrol, -+ struct snd_ctl_elem_info *uinfo); - - enum snd_soc_trigger_order { - /* start stop */ -@@ -1194,6 +1204,11 @@ struct soc_mreg_control { - unsigned int regbase, regcount, nbits, invert; - }; - -+struct soc_multi_mixer_control { -+ int min, max, platform_max, count; -+ unsigned int reg, rreg, shift, rshift, invert; -+}; -+ - /* enumerated kcontrol */ - struct soc_enum { - int reg; -diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c ---- a/sound/soc/soc-core.c -+++ b/sound/soc/soc-core.c -@@ -3366,6 +3366,39 @@ int snd_soc_get_dai_id(struct device_node *ep) - } - EXPORT_SYMBOL_GPL(snd_soc_get_dai_id); - -+/** -+ * snd_soc_info_multi_ext - external single mixer info callback -+ * @kcontrol: mixer control -+ * @uinfo: control element information -+ * -+ * Callback to provide information about a single external mixer control. -+ * that accepts multiple input. -+ * -+ * Returns 0 for success. -+ */ -+int snd_soc_info_multi_ext(struct snd_kcontrol *kcontrol, -+ struct snd_ctl_elem_info *uinfo) -+{ -+ struct soc_multi_mixer_control *mc = -+ (struct soc_multi_mixer_control *)kcontrol->private_value; -+ int platform_max; -+ -+ if (!mc->platform_max) -+ mc->platform_max = mc->max; -+ platform_max = mc->platform_max; -+ -+ if (platform_max == 1 && !strnstr(kcontrol->id.name, " Volume", 30)) -+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; -+ else -+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; -+ -+ uinfo->count = mc->count; -+ uinfo->value.integer.min = 0; -+ uinfo->value.integer.max = platform_max; -+ return 0; -+} -+EXPORT_SYMBOL_GPL(snd_soc_info_multi_ext); -+ - int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_component *dlc) - { - struct snd_soc_component *pos; diff --git a/android-mainline/NOUPSTREAM-ANDROID-gki_defconfigs.patch b/android-mainline/NOUPSTREAM-ANDROID-gki_defconfigs.patch index 53d21a84..ba6241b2 100644 --- a/android-mainline/NOUPSTREAM-ANDROID-gki_defconfigs.patch +++ b/android-mainline/NOUPSTREAM-ANDROID-gki_defconfigs.patch @@ -24,13 +24,13 @@ Signed-off-by: Lee Jones arch/arm64/configs/16k_gki.fragment | 3 + arch/arm64/configs/crashdump_defconfig | 81 +++ arch/arm64/configs/db845c_gki.fragment | 14 +- - arch/arm64/configs/gki_defconfig | 709 ++++++++++++++++++++++++ + arch/arm64/configs/gki_defconfig | 706 ++++++++++++++++++++++++ arch/arm64/configs/microdroid_defconfig | 216 ++++++++ - arch/riscv/configs/gki_defconfig | 651 ++++++++++++++++++++++ + arch/riscv/configs/gki_defconfig | 648 ++++++++++++++++++++++ arch/x86/configs/crashdump_defconfig | 87 +++ - arch/x86/configs/gki_defconfig | 657 ++++++++++++++++++++++ + arch/x86/configs/gki_defconfig | 654 ++++++++++++++++++++++ arch/x86/configs/microdroid_defconfig | 290 ++++++++++ - 9 files changed, 2705 insertions(+), 3 deletions(-) + 9 files changed, 2696 insertions(+), 3 deletions(-) create mode 100644 arch/arm64/configs/16k_gki.fragment create mode 100644 arch/arm64/configs/crashdump_defconfig create mode 100644 arch/arm64/configs/gki_defconfig @@ -194,7 +194,7 @@ diff --git a/arch/arm64/configs/gki_defconfig b/arch/arm64/configs/gki_defconfig new file mode 100644 --- /dev/null +++ b/arch/arm64/configs/gki_defconfig -@@ -0,0 +1,709 @@ +@@ -0,0 +1,706 @@ +CONFIG_UAPI_HEADER_TEST=y +CONFIG_AUDIT=y +CONFIG_NO_HZ=y @@ -689,7 +689,6 @@ new file mode 100644 +CONFIG_USB_SERIAL_FTDI_SIO=m +CONFIG_USB_GADGET=y +CONFIG_USB_CONFIGFS=y -+CONFIG_USB_CONFIGFS_UEVENT=y +CONFIG_USB_CONFIGFS_SERIAL=y +CONFIG_USB_CONFIGFS_ACM=y +CONFIG_USB_CONFIGFS_NCM=y @@ -697,8 +696,6 @@ new file mode 100644 +CONFIG_USB_CONFIGFS_EEM=y +CONFIG_USB_CONFIGFS_MASS_STORAGE=y +CONFIG_USB_CONFIGFS_F_FS=y -+CONFIG_USB_CONFIGFS_F_ACC=y -+CONFIG_USB_CONFIGFS_F_AUDIO_SRC=y +CONFIG_USB_CONFIGFS_F_UAC2=y +CONFIG_USB_CONFIGFS_F_MIDI=y +CONFIG_USB_CONFIGFS_F_HID=y @@ -1129,7 +1126,7 @@ diff --git a/arch/riscv/configs/gki_defconfig b/arch/riscv/configs/gki_defconfig new file mode 100644 --- /dev/null +++ b/arch/riscv/configs/gki_defconfig -@@ -0,0 +1,651 @@ +@@ -0,0 +1,648 @@ +CONFIG_AUDIT=y +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y @@ -1581,7 +1578,6 @@ new file mode 100644 +CONFIG_USB_SERIAL_FTDI_SIO=m +CONFIG_USB_GADGET=y +CONFIG_USB_CONFIGFS=y -+CONFIG_USB_CONFIGFS_UEVENT=y +CONFIG_USB_CONFIGFS_SERIAL=y +CONFIG_USB_CONFIGFS_ACM=y +CONFIG_USB_CONFIGFS_NCM=y @@ -1589,8 +1585,6 @@ new file mode 100644 +CONFIG_USB_CONFIGFS_EEM=y +CONFIG_USB_CONFIGFS_MASS_STORAGE=y +CONFIG_USB_CONFIGFS_F_FS=y -+CONFIG_USB_CONFIGFS_F_ACC=y -+CONFIG_USB_CONFIGFS_F_AUDIO_SRC=y +CONFIG_USB_CONFIGFS_F_UAC2=y +CONFIG_USB_CONFIGFS_F_MIDI=y +CONFIG_USB_CONFIGFS_F_HID=y @@ -1877,7 +1871,7 @@ diff --git a/arch/x86/configs/gki_defconfig b/arch/x86/configs/gki_defconfig new file mode 100644 --- /dev/null +++ b/arch/x86/configs/gki_defconfig -@@ -0,0 +1,657 @@ +@@ -0,0 +1,654 @@ +CONFIG_UAPI_HEADER_TEST=y +CONFIG_KERNEL_LZ4=y +CONFIG_AUDIT=y @@ -2339,7 +2333,6 @@ new file mode 100644 +CONFIG_USB_SERIAL_FTDI_SIO=m +CONFIG_USB_GADGET=y +CONFIG_USB_CONFIGFS=y -+CONFIG_USB_CONFIGFS_UEVENT=y +CONFIG_USB_CONFIGFS_SERIAL=y +CONFIG_USB_CONFIGFS_ACM=y +CONFIG_USB_CONFIGFS_NCM=y @@ -2347,8 +2340,6 @@ new file mode 100644 +CONFIG_USB_CONFIGFS_EEM=y +CONFIG_USB_CONFIGFS_MASS_STORAGE=y +CONFIG_USB_CONFIGFS_F_FS=y -+CONFIG_USB_CONFIGFS_F_ACC=y -+CONFIG_USB_CONFIGFS_F_AUDIO_SRC=y +CONFIG_USB_CONFIGFS_F_UAC2=y +CONFIG_USB_CONFIGFS_F_MIDI=y +CONFIG_USB_CONFIGFS_F_HID=y diff --git a/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-configfs-Add-Uevent-to-notify-userspace.patch b/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-configfs-Add-Uevent-to-notify-userspace.patch deleted file mode 100644 index d55b3400..00000000 --- a/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-configfs-Add-Uevent-to-notify-userspace.patch +++ /dev/null @@ -1,424 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Badhri Jagan Sridharan -Date: Mon, 15 Dec 2014 10:44:47 -0800 -Subject: NOUPSTREAM: ANDROID: usb: gadget: configfs: Add Uevent to notify - userspace - -Android userspace UsbDeviceManager relies on the -uevents generated by the composition driver to -generate user notifications. This CL adds uevents -to be generated whenever USB changes its state -i.e. connected, disconnected, configured. - -This CL also intercepts the setup requests from -the usb_core anb routes it to the specific -usb function if required. - -[CPNOTE: 19/07/21] Lee: Should be re-written to use upstream APIs - pinged Badhri - -Bug: 68755607 -Bug: 120441124 -Change-Id: Ib3d3a78255a532f7449dac286f776c2966caf8c1 -[badhri: Migrate to using udc uevents from upstream sysfs.] -Signed-off-by: Badhri Jagan Sridharan -[AmitP: Folded following android-4.9 commit changes into this patch - 9214c899f730 ("ANDROID: usb: gadget: configfs: handle gadget reset request for android")] -Signed-off-by: Amit Pundir -[adelva: Folded change 5c899c9fd75d ("ANDROID: usb: gadget: configfs: - fix null ptr in android_disconnect") into this patch] -Signed-off-by: Alistair Delva -[maennich: Folded change 43e98b082f9e ("ANDROID: usb: gadget: configfs: - fix compiler warning") into this patch] -Signed-off-by: Matthias Maennich -Signed-off-by: Lee Jones ---- - drivers/usb/gadget/Kconfig | 8 ++ - drivers/usb/gadget/configfs.c | 252 +++++++++++++++++++++++++++++++++- - include/linux/usb/composite.h | 1 + - 3 files changed, 259 insertions(+), 2 deletions(-) - -diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig ---- a/drivers/usb/gadget/Kconfig -+++ b/drivers/usb/gadget/Kconfig -@@ -234,6 +234,14 @@ config USB_CONFIGFS - appropriate symbolic links. - For more information see Documentation/usb/gadget_configfs.rst. - -+config USB_CONFIGFS_UEVENT -+ bool "Uevent notification of Gadget state" -+ depends on USB_CONFIGFS -+ help -+ Enable uevent notifications to userspace when the gadget -+ state changes. The gadget can be in any of the following -+ three states: "CONNECTED/DISCONNECTED/CONFIGURED" -+ - config USB_CONFIGFS_SERIAL - bool "Generic serial bulk in/out" - depends on USB_CONFIGFS -diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c ---- a/drivers/usb/gadget/configfs.c -+++ b/drivers/usb/gadget/configfs.c -@@ -12,6 +12,32 @@ - #include "u_f.h" - #include "u_os_desc.h" - -+#ifdef CONFIG_USB_CONFIGFS_UEVENT -+#include -+#include -+#include -+ -+#ifdef CONFIG_USB_CONFIGFS_F_ACC -+extern int acc_ctrlrequest(struct usb_composite_dev *cdev, -+ const struct usb_ctrlrequest *ctrl); -+void acc_disconnect(void); -+#endif -+static struct class *android_class; -+static struct device *android_device; -+static int index; -+static int gadget_index; -+ -+struct device *create_function_device(char *name) -+{ -+ if (android_device && !IS_ERR(android_device)) -+ return device_create(android_class, android_device, -+ MKDEV(0, index++), NULL, name); -+ else -+ return ERR_PTR(-EINVAL); -+} -+EXPORT_SYMBOL_GPL(create_function_device); -+#endif -+ - int check_user_usb_string(const char *name, - struct usb_gadget_strings *stringtab_dev) - { -@@ -59,6 +85,12 @@ struct gadget_info { - - spinlock_t spinlock; - bool unbind; -+#ifdef CONFIG_USB_CONFIGFS_UEVENT -+ bool connected; -+ bool sw_connected; -+ struct work_struct work; -+ struct device *dev; -+#endif - }; - - static inline struct gadget_info *to_gadget_info(struct config_item *item) -@@ -283,7 +315,7 @@ static ssize_t gadget_dev_desc_UDC_store(struct config_item *item, - - mutex_lock(&gi->lock); - -- if (!strlen(name)) { -+ if (!strlen(name) || strcmp(name, "none") == 0) { - ret = unregister_gadget(gi); - if (ret) - goto err; -@@ -1812,6 +1844,57 @@ static int configfs_composite_bind(struct usb_gadget *gadget, - return ret; - } - -+#ifdef CONFIG_USB_CONFIGFS_UEVENT -+static void android_work(struct work_struct *data) -+{ -+ struct gadget_info *gi = container_of(data, struct gadget_info, work); -+ struct usb_composite_dev *cdev = &gi->cdev; -+ char *disconnected[2] = { "USB_STATE=DISCONNECTED", NULL }; -+ char *connected[2] = { "USB_STATE=CONNECTED", NULL }; -+ char *configured[2] = { "USB_STATE=CONFIGURED", NULL }; -+ /* 0-connected 1-configured 2-disconnected*/ -+ bool status[3] = { false, false, false }; -+ unsigned long flags; -+ bool uevent_sent = false; -+ -+ spin_lock_irqsave(&cdev->lock, flags); -+ if (cdev->config) -+ status[1] = true; -+ -+ if (gi->connected != gi->sw_connected) { -+ if (gi->connected) -+ status[0] = true; -+ else -+ status[2] = true; -+ gi->sw_connected = gi->connected; -+ } -+ spin_unlock_irqrestore(&cdev->lock, flags); -+ -+ if (status[0]) { -+ kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, connected); -+ pr_info("%s: sent uevent %s\n", __func__, connected[0]); -+ uevent_sent = true; -+ } -+ -+ if (status[1]) { -+ kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, configured); -+ pr_info("%s: sent uevent %s\n", __func__, configured[0]); -+ uevent_sent = true; -+ } -+ -+ if (status[2]) { -+ kobject_uevent_env(&gi->dev->kobj, KOBJ_CHANGE, disconnected); -+ pr_info("%s: sent uevent %s\n", __func__, disconnected[0]); -+ uevent_sent = true; -+ } -+ -+ if (!uevent_sent) { -+ pr_info("%s: did not send uevent (%d %d %p)\n", __func__, -+ gi->connected, gi->sw_connected, cdev->config); -+ } -+} -+#endif -+ - static void configfs_composite_unbind(struct usb_gadget *gadget) - { - struct usb_composite_dev *cdev; -@@ -1839,6 +1922,50 @@ static void configfs_composite_unbind(struct usb_gadget *gadget) - spin_unlock_irqrestore(&gi->spinlock, flags); - } - -+#ifdef CONFIG_USB_CONFIGFS_UEVENT -+static int android_setup(struct usb_gadget *gadget, -+ const struct usb_ctrlrequest *c) -+{ -+ struct usb_composite_dev *cdev = get_gadget_data(gadget); -+ unsigned long flags; -+ struct gadget_info *gi = container_of(cdev, struct gadget_info, cdev); -+ int value = -EOPNOTSUPP; -+ struct usb_function_instance *fi; -+ -+ spin_lock_irqsave(&cdev->lock, flags); -+ if (!gi->connected) { -+ gi->connected = 1; -+ schedule_work(&gi->work); -+ } -+ spin_unlock_irqrestore(&cdev->lock, flags); -+ list_for_each_entry(fi, &gi->available_func, cfs_list) { -+ if (fi != NULL && fi->f != NULL && fi->f->setup != NULL) { -+ value = fi->f->setup(fi->f, c); -+ if (value >= 0) -+ break; -+ } -+ } -+ -+#ifdef CONFIG_USB_CONFIGFS_F_ACC -+ if (value < 0) -+ value = acc_ctrlrequest(cdev, c); -+#endif -+ -+ if (value < 0) -+ value = composite_setup(gadget, c); -+ -+ spin_lock_irqsave(&cdev->lock, flags); -+ if (c->bRequest == USB_REQ_SET_CONFIGURATION && -+ cdev->config) { -+ schedule_work(&gi->work); -+ } -+ spin_unlock_irqrestore(&cdev->lock, flags); -+ -+ return value; -+} -+ -+#else // CONFIG_USB_CONFIGFS_UEVENT -+ - static int configfs_composite_setup(struct usb_gadget *gadget, - const struct usb_ctrlrequest *ctrl) - { -@@ -1864,6 +1991,8 @@ static int configfs_composite_setup(struct usb_gadget *gadget, - return ret; - } - -+#endif // CONFIG_USB_CONFIGFS_UEVENT -+ - static void configfs_composite_disconnect(struct usb_gadget *gadget) - { - struct usb_composite_dev *cdev; -@@ -1874,6 +2003,14 @@ static void configfs_composite_disconnect(struct usb_gadget *gadget) - if (!cdev) - return; - -+#ifdef CONFIG_USB_CONFIGFS_F_ACC -+ /* -+ * accessory HID support can be active while the -+ * accessory function is not actually enabled, -+ * so we need to inform it when we are disconnected. -+ */ -+ acc_disconnect(); -+#endif - gi = container_of(cdev, struct gadget_info, cdev); - spin_lock_irqsave(&gi->spinlock, flags); - cdev = get_gadget_data(gadget); -@@ -1882,6 +2019,10 @@ static void configfs_composite_disconnect(struct usb_gadget *gadget) - return; - } - -+#ifdef CONFIG_USB_CONFIGFS_UEVENT -+ gi->connected = 0; -+ schedule_work(&gi->work); -+#endif - composite_disconnect(gadget); - spin_unlock_irqrestore(&gi->spinlock, flags); - } -@@ -1956,10 +2097,13 @@ static const struct usb_gadget_driver configfs_driver_template = { - .bind = configfs_composite_bind, - .unbind = configfs_composite_unbind, - -+#ifdef CONFIG_USB_CONFIGFS_UEVENT -+ .setup = android_setup, -+#else - .setup = configfs_composite_setup, -+#endif - .reset = configfs_composite_reset, - .disconnect = configfs_composite_disconnect, -- - .suspend = configfs_composite_suspend, - .resume = configfs_composite_resume, - -@@ -1970,6 +2114,91 @@ static const struct usb_gadget_driver configfs_driver_template = { - .match_existing_only = 1, - }; - -+#ifdef CONFIG_USB_CONFIGFS_UEVENT -+static ssize_t state_show(struct device *pdev, struct device_attribute *attr, -+ char *buf) -+{ -+ struct gadget_info *dev = dev_get_drvdata(pdev); -+ struct usb_composite_dev *cdev; -+ char *state = "DISCONNECTED"; -+ unsigned long flags; -+ -+ if (!dev) -+ goto out; -+ -+ cdev = &dev->cdev; -+ -+ if (!cdev) -+ goto out; -+ -+ spin_lock_irqsave(&cdev->lock, flags); -+ if (cdev->config) -+ state = "CONFIGURED"; -+ else if (dev->connected) -+ state = "CONNECTED"; -+ spin_unlock_irqrestore(&cdev->lock, flags); -+out: -+ return sprintf(buf, "%s\n", state); -+} -+ -+static DEVICE_ATTR(state, S_IRUGO, state_show, NULL); -+ -+static struct device_attribute *android_usb_attributes[] = { -+ &dev_attr_state, -+ NULL -+}; -+ -+static int android_device_create(struct gadget_info *gi) -+{ -+ struct device_attribute **attrs; -+ struct device_attribute *attr; -+ -+ INIT_WORK(&gi->work, android_work); -+ gi->dev = device_create(android_class, NULL, -+ MKDEV(0, 0), NULL, "android%d", gadget_index++); -+ if (IS_ERR(gi->dev)) -+ return PTR_ERR(gi->dev); -+ -+ dev_set_drvdata(gi->dev, gi); -+ if (!android_device) -+ android_device = gi->dev; -+ -+ attrs = android_usb_attributes; -+ while ((attr = *attrs++)) { -+ int err; -+ -+ err = device_create_file(gi->dev, attr); -+ if (err) { -+ device_destroy(gi->dev->class, -+ gi->dev->devt); -+ return err; -+ } -+ } -+ -+ return 0; -+} -+ -+static void android_device_destroy(struct gadget_info *gi) -+{ -+ struct device_attribute **attrs; -+ struct device_attribute *attr; -+ -+ attrs = android_usb_attributes; -+ while ((attr = *attrs++)) -+ device_remove_file(gi->dev, attr); -+ device_destroy(gi->dev->class, gi->dev->devt); -+} -+#else -+static inline int android_device_create(struct gadget_info *gi) -+{ -+ return 0; -+} -+ -+static inline void android_device_destroy(struct gadget_info *gi) -+{ -+} -+#endif -+ - static struct config_group *gadgets_make( - struct config_group *group, - const char *name) -@@ -2031,6 +2260,9 @@ static struct config_group *gadgets_make( - if (!gi->composite.gadget_driver.function) - goto out_free_driver_name; - -+ if (android_device_create(gi) < 0) -+ goto out_free_driver_name; -+ - return &gi->group; - - out_free_driver_name: -@@ -2042,7 +2274,11 @@ static struct config_group *gadgets_make( - - static void gadgets_drop(struct config_group *group, struct config_item *item) - { -+ struct gadget_info *gi; -+ -+ gi = container_of(to_config_group(item), struct gadget_info, group); - config_item_put(item); -+ android_device_destroy(gi); - } - - static struct configfs_group_operations gadgets_ops = { -@@ -2082,6 +2318,13 @@ static int __init gadget_cfs_init(void) - config_group_init(&gadget_subsys.su_group); - - ret = configfs_register_subsystem(&gadget_subsys); -+ -+#ifdef CONFIG_USB_CONFIGFS_UEVENT -+ android_class = class_create("android_usb"); -+ if (IS_ERR(android_class)) -+ return PTR_ERR(android_class); -+#endif -+ - return ret; - } - module_init(gadget_cfs_init); -@@ -2089,5 +2332,10 @@ module_init(gadget_cfs_init); - static void __exit gadget_cfs_exit(void) - { - configfs_unregister_subsystem(&gadget_subsys); -+#ifdef CONFIG_USB_CONFIGFS_UEVENT -+ if (!IS_ERR(android_class)) -+ class_destroy(android_class); -+#endif -+ - } - module_exit(gadget_cfs_exit); -diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h ---- a/include/linux/usb/composite.h -+++ b/include/linux/usb/composite.h -@@ -575,6 +575,7 @@ struct usb_function_instance { - struct config_group group; - struct list_head cfs_list; - struct usb_function_driver *fd; -+ struct usb_function *f; - int (*set_inst_name)(struct usb_function_instance *inst, - const char *name); - void (*free_func_inst)(struct usb_function_instance *inst); diff --git a/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_accessory-Add-Android-Accessory-function.patch b/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_accessory-Add-Android-Accessory-function.patch deleted file mode 100644 index 7fa8b603..00000000 --- a/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_accessory-Add-Android-Accessory-function.patch +++ /dev/null @@ -1,1877 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Benoit Goby -Date: Mon, 19 Dec 2011 14:39:37 -0800 -Subject: NOUPSTREAM: ANDROID: usb: gadget: f_accessory: Add Android Accessory - function - -USB accessory mode allows users to connect USB host hardware -specifically designed for Android-powered devices. The accessories -must adhere to the Android accessory protocol outlined in the -http://accessories.android.com documentation. This allows -Android devices that cannot act as a USB host to still interact with -USB hardware. When an Android device is in USB accessory mode, the -attached Android USB accessory acts as the host, provides power -to the USB bus, and enumerates connected devices. - -[CPNOTE: 19/07/21] Lee: Should be re-written to use upstream APIs - pinged Badhri - -Bug: 63740241 -Bug: 120441124 -Bug: 223101878 -Change-Id: I67964b50d278f3c0471d47efbb7b0973a3502681 -[badhri: f_accessory is being migrated to userspace.] -Signed-off-by: Mike Lockwood -[AmitP: Folded following android-4.9 commit changes into this patch - ceb2f0aac624 ("ANDROID: usb: gadget: accessory: Fix section mismatch") - Parts of e27543931009 ("ANDROID: usb: gadget: Fixes and hacks to make android usb gadget compile on 3.8") - 1b07ec751563 ("ANDROID: drivers: usb: gadget: 64-bit related type fixes")] -Signed-off-by: Amit Pundir -[adelva: Folded the following changes into this patch: - 9d5891d516e2 ("ANDROID: usb: gadget: f_accessory: Add ACCESSORY_SET_AUDIO_MODE control request and ioctl") - dc66cfce9622 ("ANDROID: usb: gadget: f_accessory: Add support for HID input devices") - 5f1ac9c2871b ("ANDROID: usb: gadget: f_accessory: move userspace interface to uapi") - 9a6241722cd8 ("ANDROID: usb: gadget: f_accessory: Enabled Zero Length Packet (ZLP) for acc_write") - 31a0ecd5a825 ("ANDROID: usb: gadget: f_accessory: check for accessory device before disconnecting HIDs") - 580721fa6cbc ("ANDROID: usb: gadget: f_accessory: Migrate to USB_FUNCTION API") - 7f407172fb28 ("ANDROID: usb: gadget: f_accessory: Fix for UsbAccessory clean unbind.") - ebc98ac5a22f ("ANDROID: usb: gadget: f_accessory: fix false disconnect due to a signal sent to the reading process") - 71c6dc5ffdab ("ANDROID: usb: gadget: f_accessory: assign no-op request complete callbacks") - 675047ee68e9 ("ANDROID: usb: gadget: f_accessory: Move gadget functions code") - b2bedaa5c7df ("CHROMIUM: usb: gadget: f_accessory: add .raw_request callback")] -Signed-off-by: Alistair Delva -[maennich: Folded the following patch in this patch: - f4f6f40ebc62 ("ANDROID: usb: gadget: Fix dependency for f_accessory")] -Signed-off-by: Matthias Maennich -[ebiggers: Folded in the following commit: - fd734b5e295a ("ANDROID: USB: f_accessory: Check dev pointer before decoding ctrl request")] -Signed-off-by: Eric Biggers - ANDROID: usb: gadget: f_accessory: add compat_ioctl support -Signed-off-by: Lee Jones ---- - drivers/usb/gadget/Kconfig | 11 + - drivers/usb/gadget/configfs.c | 4 +- - drivers/usb/gadget/function/Makefile | 2 + - drivers/usb/gadget/function/f_accessory.c | 1574 +++++++++++++++++++++ - include/linux/usb/f_accessory.h | 23 + - include/uapi/linux/usb/f_accessory.h | 146 ++ - 6 files changed, 1758 insertions(+), 2 deletions(-) - create mode 100644 drivers/usb/gadget/function/f_accessory.c - create mode 100644 include/linux/usb/f_accessory.h - create mode 100644 include/uapi/linux/usb/f_accessory.h - -diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig ---- a/drivers/usb/gadget/Kconfig -+++ b/drivers/usb/gadget/Kconfig -@@ -220,6 +220,9 @@ config USB_F_PRINTER - config USB_F_TCM - tristate - -+config USB_F_ACC -+ tristate -+ - # this first set of drivers all depend on bulk-capable hardware. - - config USB_CONFIGFS -@@ -383,6 +386,14 @@ 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_ACC -+ bool "Accessory gadget" -+ depends on USB_CONFIGFS -+ depends on HID=y -+ select USB_F_ACC -+ help -+ USB gadget Accessory support -+ - config USB_CONFIGFS_F_UAC1 - bool "Audio Class 1.0" - depends on USB_CONFIGFS -diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c ---- a/drivers/usb/gadget/configfs.c -+++ b/drivers/usb/gadget/configfs.c -@@ -18,7 +18,7 @@ - #include - - #ifdef CONFIG_USB_CONFIGFS_F_ACC --extern int acc_ctrlrequest(struct usb_composite_dev *cdev, -+extern int acc_ctrlrequest_composite(struct usb_composite_dev *cdev, - const struct usb_ctrlrequest *ctrl); - void acc_disconnect(void); - #endif -@@ -1948,7 +1948,7 @@ static int android_setup(struct usb_gadget *gadget, - - #ifdef CONFIG_USB_CONFIGFS_F_ACC - if (value < 0) -- value = acc_ctrlrequest(cdev, c); -+ value = acc_ctrlrequest_composite(cdev, c); - #endif - - if (value < 0) -diff --git a/drivers/usb/gadget/function/Makefile b/drivers/usb/gadget/function/Makefile ---- a/drivers/usb/gadget/function/Makefile -+++ b/drivers/usb/gadget/function/Makefile -@@ -52,3 +52,5 @@ usb_f_printer-y := f_printer.o - obj-$(CONFIG_USB_F_PRINTER) += usb_f_printer.o - usb_f_tcm-y := f_tcm.o - obj-$(CONFIG_USB_F_TCM) += usb_f_tcm.o -+usb_f_accessory-y := f_accessory.o -+obj-$(CONFIG_USB_F_ACC) += usb_f_accessory.o -diff --git a/drivers/usb/gadget/function/f_accessory.c b/drivers/usb/gadget/function/f_accessory.c -new file mode 100644 ---- /dev/null -+++ b/drivers/usb/gadget/function/f_accessory.c -@@ -0,0 +1,1574 @@ -+// SPDX-License-Identifier: GPL-2.0 -+/* -+ * Gadget Function Driver for Android USB accessories -+ * -+ * Copyright (C) 2011 Google, Inc. -+ * Author: Mike Lockwood -+ * -+ * This software is licensed under the terms of the GNU General Public -+ * License version 2, as published by the Free Software Foundation, and -+ * may be copied, distributed, and modified under those terms. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ */ -+ -+/* #define DEBUG */ -+/* #define VERBOSE_DEBUG */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+#define MAX_INST_NAME_LEN 40 -+#define BULK_BUFFER_SIZE 16384 -+#define ACC_STRING_SIZE 256 -+ -+#define PROTOCOL_VERSION 2 -+ -+/* String IDs */ -+#define INTERFACE_STRING_INDEX 0 -+ -+/* number of tx and rx requests to allocate */ -+#define TX_REQ_MAX 4 -+#define RX_REQ_MAX 2 -+ -+struct acc_hid_dev { -+ struct list_head list; -+ struct hid_device *hid; -+ struct acc_dev *dev; -+ /* accessory defined ID */ -+ int id; -+ /* HID report descriptor */ -+ u8 *report_desc; -+ /* length of HID report descriptor */ -+ int report_desc_len; -+ /* number of bytes of report_desc we have received so far */ -+ int report_desc_offset; -+}; -+ -+struct acc_dev { -+ struct usb_function function; -+ struct usb_composite_dev *cdev; -+ spinlock_t lock; -+ struct acc_dev_ref *ref; -+ -+ struct usb_ep *ep_in; -+ struct usb_ep *ep_out; -+ -+ /* online indicates state of function_set_alt & function_unbind -+ * set to 1 when we connect -+ */ -+ int online; -+ -+ /* disconnected indicates state of open & release -+ * Set to 1 when we disconnect. -+ * Not cleared until our file is closed. -+ */ -+ int disconnected; -+ -+ /* strings sent by the host */ -+ char manufacturer[ACC_STRING_SIZE]; -+ char model[ACC_STRING_SIZE]; -+ char description[ACC_STRING_SIZE]; -+ char version[ACC_STRING_SIZE]; -+ char uri[ACC_STRING_SIZE]; -+ char serial[ACC_STRING_SIZE]; -+ -+ /* for acc_complete_set_string */ -+ int string_index; -+ -+ /* set to 1 if we have a pending start request */ -+ int start_requested; -+ -+ int audio_mode; -+ -+ /* synchronize access to our device file */ -+ atomic_t open_excl; -+ -+ struct list_head tx_idle; -+ -+ wait_queue_head_t read_wq; -+ wait_queue_head_t write_wq; -+ struct usb_request *rx_req[RX_REQ_MAX]; -+ int rx_done; -+ -+ /* delayed work for handling ACCESSORY_START */ -+ struct delayed_work start_work; -+ -+ /* work for handling ACCESSORY GET PROTOCOL */ -+ struct work_struct getprotocol_work; -+ -+ /* work for handling ACCESSORY SEND STRING */ -+ struct work_struct sendstring_work; -+ -+ /* worker for registering and unregistering hid devices */ -+ struct work_struct hid_work; -+ -+ /* list of active HID devices */ -+ struct list_head hid_list; -+ -+ /* list of new HID devices to register */ -+ struct list_head new_hid_list; -+ -+ /* list of dead HID devices to unregister */ -+ struct list_head dead_hid_list; -+}; -+ -+static struct usb_interface_descriptor acc_interface_desc = { -+ .bLength = USB_DT_INTERFACE_SIZE, -+ .bDescriptorType = USB_DT_INTERFACE, -+ .bInterfaceNumber = 0, -+ .bNumEndpoints = 2, -+ .bInterfaceClass = USB_CLASS_VENDOR_SPEC, -+ .bInterfaceSubClass = USB_SUBCLASS_VENDOR_SPEC, -+ .bInterfaceProtocol = 0, -+}; -+ -+static struct usb_endpoint_descriptor acc_superspeedplus_in_desc = { -+ .bLength = USB_DT_ENDPOINT_SIZE, -+ .bDescriptorType = USB_DT_ENDPOINT, -+ .bEndpointAddress = USB_DIR_IN, -+ .bmAttributes = USB_ENDPOINT_XFER_BULK, -+ .wMaxPacketSize = cpu_to_le16(1024), -+}; -+ -+static struct usb_endpoint_descriptor acc_superspeedplus_out_desc = { -+ .bLength = USB_DT_ENDPOINT_SIZE, -+ .bDescriptorType = USB_DT_ENDPOINT, -+ .bEndpointAddress = USB_DIR_OUT, -+ .bmAttributes = USB_ENDPOINT_XFER_BULK, -+ .wMaxPacketSize = cpu_to_le16(1024), -+}; -+ -+static struct usb_ss_ep_comp_descriptor acc_superspeedplus_comp_desc = { -+ .bLength = sizeof(acc_superspeedplus_comp_desc), -+ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, -+ -+ /* the following 2 values can be tweaked if necessary */ -+ /* .bMaxBurst = 0, */ -+ /* .bmAttributes = 0, */ -+}; -+ -+static struct usb_endpoint_descriptor acc_superspeed_in_desc = { -+ .bLength = USB_DT_ENDPOINT_SIZE, -+ .bDescriptorType = USB_DT_ENDPOINT, -+ .bEndpointAddress = USB_DIR_IN, -+ .bmAttributes = USB_ENDPOINT_XFER_BULK, -+ .wMaxPacketSize = cpu_to_le16(1024), -+}; -+ -+static struct usb_endpoint_descriptor acc_superspeed_out_desc = { -+ .bLength = USB_DT_ENDPOINT_SIZE, -+ .bDescriptorType = USB_DT_ENDPOINT, -+ .bEndpointAddress = USB_DIR_OUT, -+ .bmAttributes = USB_ENDPOINT_XFER_BULK, -+ .wMaxPacketSize = cpu_to_le16(1024), -+}; -+ -+static struct usb_ss_ep_comp_descriptor acc_superspeed_comp_desc = { -+ .bLength = sizeof(acc_superspeed_comp_desc), -+ .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, -+ -+ /* the following 2 values can be tweaked if necessary */ -+ /* .bMaxBurst = 0, */ -+ /* .bmAttributes = 0, */ -+}; -+ -+static struct usb_endpoint_descriptor acc_highspeed_in_desc = { -+ .bLength = USB_DT_ENDPOINT_SIZE, -+ .bDescriptorType = USB_DT_ENDPOINT, -+ .bEndpointAddress = USB_DIR_IN, -+ .bmAttributes = USB_ENDPOINT_XFER_BULK, -+ .wMaxPacketSize = cpu_to_le16(512), -+}; -+ -+static struct usb_endpoint_descriptor acc_highspeed_out_desc = { -+ .bLength = USB_DT_ENDPOINT_SIZE, -+ .bDescriptorType = USB_DT_ENDPOINT, -+ .bEndpointAddress = USB_DIR_OUT, -+ .bmAttributes = USB_ENDPOINT_XFER_BULK, -+ .wMaxPacketSize = cpu_to_le16(512), -+}; -+ -+static struct usb_endpoint_descriptor acc_fullspeed_in_desc = { -+ .bLength = USB_DT_ENDPOINT_SIZE, -+ .bDescriptorType = USB_DT_ENDPOINT, -+ .bEndpointAddress = USB_DIR_IN, -+ .bmAttributes = USB_ENDPOINT_XFER_BULK, -+}; -+ -+static struct usb_endpoint_descriptor acc_fullspeed_out_desc = { -+ .bLength = USB_DT_ENDPOINT_SIZE, -+ .bDescriptorType = USB_DT_ENDPOINT, -+ .bEndpointAddress = USB_DIR_OUT, -+ .bmAttributes = USB_ENDPOINT_XFER_BULK, -+}; -+ -+static struct usb_descriptor_header *fs_acc_descs[] = { -+ (struct usb_descriptor_header *) &acc_interface_desc, -+ (struct usb_descriptor_header *) &acc_fullspeed_in_desc, -+ (struct usb_descriptor_header *) &acc_fullspeed_out_desc, -+ NULL, -+}; -+ -+static struct usb_descriptor_header *hs_acc_descs[] = { -+ (struct usb_descriptor_header *) &acc_interface_desc, -+ (struct usb_descriptor_header *) &acc_highspeed_in_desc, -+ (struct usb_descriptor_header *) &acc_highspeed_out_desc, -+ NULL, -+}; -+ -+static struct usb_descriptor_header *ss_acc_descs[] = { -+ (struct usb_descriptor_header *) &acc_interface_desc, -+ (struct usb_descriptor_header *) &acc_superspeed_in_desc, -+ (struct usb_descriptor_header *) &acc_superspeed_comp_desc, -+ (struct usb_descriptor_header *) &acc_superspeed_out_desc, -+ (struct usb_descriptor_header *) &acc_superspeed_comp_desc, -+ NULL, -+}; -+ -+static struct usb_descriptor_header *ssp_acc_descs[] = { -+ (struct usb_descriptor_header *) &acc_interface_desc, -+ (struct usb_descriptor_header *) &acc_superspeedplus_in_desc, -+ (struct usb_descriptor_header *) &acc_superspeedplus_comp_desc, -+ (struct usb_descriptor_header *) &acc_superspeedplus_out_desc, -+ (struct usb_descriptor_header *) &acc_superspeedplus_comp_desc, -+ NULL, -+}; -+ -+static struct usb_string acc_string_defs[] = { -+ [INTERFACE_STRING_INDEX].s = "Android Accessory Interface", -+ { }, /* end of list */ -+}; -+ -+static struct usb_gadget_strings acc_string_table = { -+ .language = 0x0409, /* en-US */ -+ .strings = acc_string_defs, -+}; -+ -+static struct usb_gadget_strings *acc_strings[] = { -+ &acc_string_table, -+ NULL, -+}; -+ -+struct acc_dev_ref { -+ struct kref kref; -+ struct acc_dev *acc_dev; -+}; -+ -+static struct acc_dev_ref _acc_dev_ref = { -+ .kref = KREF_INIT(0), -+}; -+ -+struct acc_instance { -+ struct usb_function_instance func_inst; -+ const char *name; -+}; -+ -+static struct acc_dev *get_acc_dev(void) -+{ -+ struct acc_dev_ref *ref = &_acc_dev_ref; -+ -+ return kref_get_unless_zero(&ref->kref) ? ref->acc_dev : NULL; -+} -+ -+static void __put_acc_dev(struct kref *kref) -+{ -+ struct acc_dev_ref *ref = container_of(kref, struct acc_dev_ref, kref); -+ struct acc_dev *dev = ref->acc_dev; -+ -+ /* Cancel any async work */ -+ cancel_delayed_work_sync(&dev->start_work); -+ cancel_work_sync(&dev->getprotocol_work); -+ cancel_work_sync(&dev->sendstring_work); -+ cancel_work_sync(&dev->hid_work); -+ -+ ref->acc_dev = NULL; -+ kfree(dev); -+} -+ -+static void put_acc_dev(struct acc_dev *dev) -+{ -+ struct acc_dev_ref *ref = dev->ref; -+ -+ WARN_ON(ref->acc_dev != dev); -+ kref_put(&ref->kref, __put_acc_dev); -+} -+ -+static inline struct acc_dev *func_to_dev(struct usb_function *f) -+{ -+ return container_of(f, struct acc_dev, function); -+} -+ -+static struct usb_request *acc_request_new(struct usb_ep *ep, int buffer_size) -+{ -+ struct usb_request *req = usb_ep_alloc_request(ep, GFP_KERNEL); -+ -+ if (!req) -+ return NULL; -+ -+ /* now allocate buffers for the requests */ -+ req->buf = kmalloc(buffer_size, GFP_KERNEL); -+ if (!req->buf) { -+ usb_ep_free_request(ep, req); -+ return NULL; -+ } -+ -+ return req; -+} -+ -+static void acc_request_free(struct usb_request *req, struct usb_ep *ep) -+{ -+ if (req) { -+ kfree(req->buf); -+ usb_ep_free_request(ep, req); -+ } -+} -+ -+/* add a request to the tail of a list */ -+static void req_put(struct acc_dev *dev, struct list_head *head, -+ struct usb_request *req) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave(&dev->lock, flags); -+ list_add_tail(&req->list, head); -+ spin_unlock_irqrestore(&dev->lock, flags); -+} -+ -+/* remove a request from the head of a list */ -+static struct usb_request *req_get(struct acc_dev *dev, struct list_head *head) -+{ -+ unsigned long flags; -+ struct usb_request *req; -+ -+ spin_lock_irqsave(&dev->lock, flags); -+ if (list_empty(head)) { -+ req = 0; -+ } else { -+ req = list_first_entry(head, struct usb_request, list); -+ list_del(&req->list); -+ } -+ spin_unlock_irqrestore(&dev->lock, flags); -+ return req; -+} -+ -+static void acc_set_disconnected(struct acc_dev *dev) -+{ -+ dev->disconnected = 1; -+} -+ -+static void acc_complete_in(struct usb_ep *ep, struct usb_request *req) -+{ -+ struct acc_dev *dev = get_acc_dev(); -+ -+ if (!dev) -+ return; -+ -+ if (req->status == -ESHUTDOWN) { -+ pr_debug("acc_complete_in set disconnected"); -+ acc_set_disconnected(dev); -+ } -+ -+ req_put(dev, &dev->tx_idle, req); -+ -+ wake_up(&dev->write_wq); -+ put_acc_dev(dev); -+} -+ -+static void acc_complete_out(struct usb_ep *ep, struct usb_request *req) -+{ -+ struct acc_dev *dev = get_acc_dev(); -+ -+ if (!dev) -+ return; -+ -+ dev->rx_done = 1; -+ if (req->status == -ESHUTDOWN) { -+ pr_debug("acc_complete_out set disconnected"); -+ acc_set_disconnected(dev); -+ } -+ -+ wake_up(&dev->read_wq); -+ put_acc_dev(dev); -+} -+ -+static void acc_complete_set_string(struct usb_ep *ep, struct usb_request *req) -+{ -+ struct acc_dev *dev = ep->driver_data; -+ char *string_dest = NULL; -+ int length = req->actual; -+ -+ if (req->status != 0) { -+ pr_err("acc_complete_set_string, err %d\n", req->status); -+ return; -+ } -+ -+ switch (dev->string_index) { -+ case ACCESSORY_STRING_MANUFACTURER: -+ string_dest = dev->manufacturer; -+ break; -+ case ACCESSORY_STRING_MODEL: -+ string_dest = dev->model; -+ break; -+ case ACCESSORY_STRING_DESCRIPTION: -+ string_dest = dev->description; -+ break; -+ case ACCESSORY_STRING_VERSION: -+ string_dest = dev->version; -+ break; -+ case ACCESSORY_STRING_URI: -+ string_dest = dev->uri; -+ break; -+ case ACCESSORY_STRING_SERIAL: -+ string_dest = dev->serial; -+ break; -+ } -+ if (string_dest) { -+ unsigned long flags; -+ -+ if (length >= ACC_STRING_SIZE) -+ length = ACC_STRING_SIZE - 1; -+ -+ spin_lock_irqsave(&dev->lock, flags); -+ memcpy(string_dest, req->buf, length); -+ /* ensure zero termination */ -+ string_dest[length] = 0; -+ spin_unlock_irqrestore(&dev->lock, flags); -+ } else { -+ pr_err("unknown accessory string index %d\n", -+ dev->string_index); -+ } -+} -+ -+static void acc_complete_set_hid_report_desc(struct usb_ep *ep, -+ struct usb_request *req) -+{ -+ struct acc_hid_dev *hid = req->context; -+ struct acc_dev *dev = hid->dev; -+ int length = req->actual; -+ -+ if (req->status != 0) { -+ pr_err("acc_complete_set_hid_report_desc, err %d\n", -+ req->status); -+ return; -+ } -+ -+ memcpy(hid->report_desc + hid->report_desc_offset, req->buf, length); -+ hid->report_desc_offset += length; -+ if (hid->report_desc_offset == hid->report_desc_len) { -+ /* After we have received the entire report descriptor -+ * we schedule work to initialize the HID device -+ */ -+ schedule_work(&dev->hid_work); -+ } -+} -+ -+static void acc_complete_send_hid_event(struct usb_ep *ep, -+ struct usb_request *req) -+{ -+ struct acc_hid_dev *hid = req->context; -+ int length = req->actual; -+ -+ if (req->status != 0) { -+ pr_err("acc_complete_send_hid_event, err %d\n", req->status); -+ return; -+ } -+ -+ hid_report_raw_event(hid->hid, HID_INPUT_REPORT, req->buf, length, 1); -+} -+ -+static int acc_hid_parse(struct hid_device *hid) -+{ -+ struct acc_hid_dev *hdev = hid->driver_data; -+ -+ hid_parse_report(hid, hdev->report_desc, hdev->report_desc_len); -+ return 0; -+} -+ -+static int acc_hid_start(struct hid_device *hid) -+{ -+ return 0; -+} -+ -+static void acc_hid_stop(struct hid_device *hid) -+{ -+} -+ -+static int acc_hid_open(struct hid_device *hid) -+{ -+ return 0; -+} -+ -+static void acc_hid_close(struct hid_device *hid) -+{ -+} -+ -+static int acc_hid_raw_request(struct hid_device *hid, unsigned char reportnum, -+ __u8 *buf, size_t len, unsigned char rtype, int reqtype) -+{ -+ return 0; -+} -+ -+static struct hid_ll_driver acc_hid_ll_driver = { -+ .parse = acc_hid_parse, -+ .start = acc_hid_start, -+ .stop = acc_hid_stop, -+ .open = acc_hid_open, -+ .close = acc_hid_close, -+ .raw_request = acc_hid_raw_request, -+}; -+ -+static struct acc_hid_dev *acc_hid_new(struct acc_dev *dev, -+ int id, int desc_len) -+{ -+ struct acc_hid_dev *hdev; -+ -+ hdev = kzalloc(sizeof(*hdev), GFP_ATOMIC); -+ if (!hdev) -+ return NULL; -+ hdev->report_desc = kzalloc(desc_len, GFP_ATOMIC); -+ if (!hdev->report_desc) { -+ kfree(hdev); -+ return NULL; -+ } -+ hdev->dev = dev; -+ hdev->id = id; -+ hdev->report_desc_len = desc_len; -+ -+ return hdev; -+} -+ -+static struct acc_hid_dev *acc_hid_get(struct list_head *list, int id) -+{ -+ struct acc_hid_dev *hid; -+ -+ list_for_each_entry(hid, list, list) { -+ if (hid->id == id) -+ return hid; -+ } -+ return NULL; -+} -+ -+static int acc_register_hid(struct acc_dev *dev, int id, int desc_length) -+{ -+ struct acc_hid_dev *hid; -+ unsigned long flags; -+ -+ /* report descriptor length must be > 0 */ -+ if (desc_length <= 0) -+ return -EINVAL; -+ -+ spin_lock_irqsave(&dev->lock, flags); -+ /* replace HID if one already exists with this ID */ -+ hid = acc_hid_get(&dev->hid_list, id); -+ if (!hid) -+ hid = acc_hid_get(&dev->new_hid_list, id); -+ if (hid) -+ list_move(&hid->list, &dev->dead_hid_list); -+ -+ hid = acc_hid_new(dev, id, desc_length); -+ if (!hid) { -+ spin_unlock_irqrestore(&dev->lock, flags); -+ return -ENOMEM; -+ } -+ -+ list_add(&hid->list, &dev->new_hid_list); -+ spin_unlock_irqrestore(&dev->lock, flags); -+ -+ /* schedule work to register the HID device */ -+ schedule_work(&dev->hid_work); -+ return 0; -+} -+ -+static int acc_unregister_hid(struct acc_dev *dev, int id) -+{ -+ struct acc_hid_dev *hid; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&dev->lock, flags); -+ hid = acc_hid_get(&dev->hid_list, id); -+ if (!hid) -+ hid = acc_hid_get(&dev->new_hid_list, id); -+ if (!hid) { -+ spin_unlock_irqrestore(&dev->lock, flags); -+ return -EINVAL; -+ } -+ -+ list_move(&hid->list, &dev->dead_hid_list); -+ spin_unlock_irqrestore(&dev->lock, flags); -+ -+ schedule_work(&dev->hid_work); -+ return 0; -+} -+ -+static int create_bulk_endpoints(struct acc_dev *dev, -+ struct usb_endpoint_descriptor *in_desc, -+ struct usb_endpoint_descriptor *out_desc) -+{ -+ struct usb_composite_dev *cdev = dev->cdev; -+ struct usb_request *req; -+ struct usb_ep *ep; -+ int i; -+ -+ DBG(cdev, "create_bulk_endpoints dev: %p\n", dev); -+ -+ ep = usb_ep_autoconfig(cdev->gadget, in_desc); -+ if (!ep) { -+ DBG(cdev, "usb_ep_autoconfig for ep_in failed\n"); -+ return -ENODEV; -+ } -+ DBG(cdev, "usb_ep_autoconfig for ep_in got %s\n", ep->name); -+ ep->driver_data = dev; /* claim the endpoint */ -+ dev->ep_in = ep; -+ -+ ep = usb_ep_autoconfig(cdev->gadget, out_desc); -+ if (!ep) { -+ DBG(cdev, "usb_ep_autoconfig for ep_out failed\n"); -+ return -ENODEV; -+ } -+ DBG(cdev, "usb_ep_autoconfig for ep_out got %s\n", ep->name); -+ ep->driver_data = dev; /* claim the endpoint */ -+ dev->ep_out = ep; -+ -+ /* now allocate requests for our endpoints */ -+ for (i = 0; i < TX_REQ_MAX; i++) { -+ req = acc_request_new(dev->ep_in, BULK_BUFFER_SIZE); -+ if (!req) -+ goto fail; -+ req->complete = acc_complete_in; -+ req_put(dev, &dev->tx_idle, req); -+ } -+ for (i = 0; i < RX_REQ_MAX; i++) { -+ req = acc_request_new(dev->ep_out, BULK_BUFFER_SIZE); -+ if (!req) -+ goto fail; -+ req->complete = acc_complete_out; -+ dev->rx_req[i] = req; -+ } -+ -+ return 0; -+ -+fail: -+ pr_err("acc_bind() could not allocate requests\n"); -+ while ((req = req_get(dev, &dev->tx_idle))) -+ acc_request_free(req, dev->ep_in); -+ for (i = 0; i < RX_REQ_MAX; i++) { -+ acc_request_free(dev->rx_req[i], dev->ep_out); -+ dev->rx_req[i] = NULL; -+ } -+ -+ return -1; -+} -+ -+static ssize_t acc_read(struct file *fp, char __user *buf, -+ size_t count, loff_t *pos) -+{ -+ struct acc_dev *dev = fp->private_data; -+ struct usb_request *req; -+ ssize_t r = count; -+ ssize_t data_length; -+ unsigned xfer; -+ int ret = 0; -+ -+ pr_debug("acc_read(%zu)\n", count); -+ -+ if (dev->disconnected) { -+ pr_debug("acc_read disconnected"); -+ return -ENODEV; -+ } -+ -+ if (count > BULK_BUFFER_SIZE) -+ count = BULK_BUFFER_SIZE; -+ -+ /* we will block until we're online */ -+ pr_debug("acc_read: waiting for online\n"); -+ ret = wait_event_interruptible(dev->read_wq, dev->online); -+ if (ret < 0) { -+ r = ret; -+ goto done; -+ } -+ -+ if (!dev->rx_req[0]) { -+ pr_warn("acc_read: USB request already handled/freed"); -+ r = -EINVAL; -+ goto done; -+ } -+ -+ /* -+ * Calculate the data length by considering termination character. -+ * Then compansite the difference of rounding up to -+ * integer multiple of maxpacket size. -+ */ -+ data_length = count; -+ data_length += dev->ep_out->maxpacket - 1; -+ data_length -= data_length % dev->ep_out->maxpacket; -+ -+ if (dev->rx_done) { -+ // last req cancelled. try to get it. -+ req = dev->rx_req[0]; -+ goto copy_data; -+ } -+ -+requeue_req: -+ /* queue a request */ -+ req = dev->rx_req[0]; -+ req->length = data_length; -+ dev->rx_done = 0; -+ ret = usb_ep_queue(dev->ep_out, req, GFP_KERNEL); -+ if (ret < 0) { -+ r = -EIO; -+ goto done; -+ } else { -+ pr_debug("rx %p queue\n", req); -+ } -+ -+ /* wait for a request to complete */ -+ ret = wait_event_interruptible(dev->read_wq, dev->rx_done); -+ if (ret < 0) { -+ r = ret; -+ ret = usb_ep_dequeue(dev->ep_out, req); -+ if (ret != 0) { -+ // cancel failed. There can be a data already received. -+ // it will be retrieved in the next read. -+ pr_debug("acc_read: cancelling failed %d", ret); -+ } -+ goto done; -+ } -+ -+copy_data: -+ dev->rx_done = 0; -+ if (dev->online) { -+ /* If we got a 0-len packet, throw it back and try again. */ -+ if (req->actual == 0) -+ goto requeue_req; -+ -+ pr_debug("rx %p %u\n", req, req->actual); -+ xfer = (req->actual < count) ? req->actual : count; -+ r = xfer; -+ if (copy_to_user(buf, req->buf, xfer)) -+ r = -EFAULT; -+ } else -+ r = -EIO; -+ -+done: -+ pr_debug("acc_read returning %zd\n", r); -+ return r; -+} -+ -+static ssize_t acc_write(struct file *fp, const char __user *buf, -+ size_t count, loff_t *pos) -+{ -+ struct acc_dev *dev = fp->private_data; -+ struct usb_request *req = 0; -+ ssize_t r = count; -+ unsigned xfer; -+ int ret; -+ -+ pr_debug("acc_write(%zu)\n", count); -+ -+ if (!dev->online || dev->disconnected) { -+ pr_debug("acc_write disconnected or not online"); -+ return -ENODEV; -+ } -+ -+ while (count > 0) { -+ /* get an idle tx request to use */ -+ req = 0; -+ ret = wait_event_interruptible(dev->write_wq, -+ ((req = req_get(dev, &dev->tx_idle)) || !dev->online)); -+ if (!dev->online || dev->disconnected) { -+ pr_debug("acc_write dev->error\n"); -+ r = -EIO; -+ break; -+ } -+ -+ if (!req) { -+ r = ret; -+ break; -+ } -+ -+ if (count > BULK_BUFFER_SIZE) { -+ xfer = BULK_BUFFER_SIZE; -+ /* ZLP, They will be more TX requests so not yet. */ -+ req->zero = 0; -+ } else { -+ xfer = count; -+ /* If the data length is a multple of the -+ * maxpacket size then send a zero length packet(ZLP). -+ */ -+ req->zero = ((xfer % dev->ep_in->maxpacket) == 0); -+ } -+ if (copy_from_user(req->buf, buf, xfer)) { -+ r = -EFAULT; -+ break; -+ } -+ -+ req->length = xfer; -+ ret = usb_ep_queue(dev->ep_in, req, GFP_KERNEL); -+ if (ret < 0) { -+ pr_debug("acc_write: xfer error %d\n", ret); -+ r = -EIO; -+ break; -+ } -+ -+ buf += xfer; -+ count -= xfer; -+ -+ /* zero this so we don't try to free it on error exit */ -+ req = 0; -+ } -+ -+ if (req) -+ req_put(dev, &dev->tx_idle, req); -+ -+ pr_debug("acc_write returning %zd\n", r); -+ return r; -+} -+ -+static long acc_ioctl(struct file *fp, unsigned code, unsigned long value) -+{ -+ struct acc_dev *dev = fp->private_data; -+ char *src = NULL; -+ int ret; -+ -+ switch (code) { -+ case ACCESSORY_GET_STRING_MANUFACTURER: -+ src = dev->manufacturer; -+ break; -+ case ACCESSORY_GET_STRING_MODEL: -+ src = dev->model; -+ break; -+ case ACCESSORY_GET_STRING_DESCRIPTION: -+ src = dev->description; -+ break; -+ case ACCESSORY_GET_STRING_VERSION: -+ src = dev->version; -+ break; -+ case ACCESSORY_GET_STRING_URI: -+ src = dev->uri; -+ break; -+ case ACCESSORY_GET_STRING_SERIAL: -+ src = dev->serial; -+ break; -+ case ACCESSORY_IS_START_REQUESTED: -+ return dev->start_requested; -+ case ACCESSORY_GET_AUDIO_MODE: -+ return dev->audio_mode; -+ } -+ if (!src) -+ return -EINVAL; -+ -+ ret = strlen(src) + 1; -+ if (copy_to_user((void __user *)value, src, ret)) -+ ret = -EFAULT; -+ return ret; -+} -+ -+static int acc_open(struct inode *ip, struct file *fp) -+{ -+ struct acc_dev *dev = get_acc_dev(); -+ -+ if (!dev) -+ return -ENODEV; -+ -+ if (atomic_xchg(&dev->open_excl, 1)) { -+ put_acc_dev(dev); -+ return -EBUSY; -+ } -+ -+ dev->disconnected = 0; -+ fp->private_data = dev; -+ return 0; -+} -+ -+static int acc_release(struct inode *ip, struct file *fp) -+{ -+ struct acc_dev *dev = fp->private_data; -+ -+ if (!dev) -+ return -ENOENT; -+ -+ /* indicate that we are disconnected -+ * still could be online so don't touch online flag -+ */ -+ dev->disconnected = 1; -+ -+ fp->private_data = NULL; -+ WARN_ON(!atomic_xchg(&dev->open_excl, 0)); -+ put_acc_dev(dev); -+ return 0; -+} -+ -+/* file operations for /dev/usb_accessory */ -+static const struct file_operations acc_fops = { -+ .owner = THIS_MODULE, -+ .read = acc_read, -+ .write = acc_write, -+ .unlocked_ioctl = acc_ioctl, -+ .compat_ioctl = acc_ioctl, -+ .open = acc_open, -+ .release = acc_release, -+}; -+ -+static int acc_hid_probe(struct hid_device *hdev, -+ const struct hid_device_id *id) -+{ -+ int ret; -+ -+ ret = hid_parse(hdev); -+ if (ret) -+ return ret; -+ return hid_hw_start(hdev, HID_CONNECT_DEFAULT); -+} -+ -+static struct miscdevice acc_device = { -+ .minor = MISC_DYNAMIC_MINOR, -+ .name = "usb_accessory", -+ .fops = &acc_fops, -+}; -+ -+static const struct hid_device_id acc_hid_table[] = { -+ { HID_USB_DEVICE(HID_ANY_ID, HID_ANY_ID) }, -+ { } -+}; -+ -+static struct hid_driver acc_hid_driver = { -+ .name = "USB accessory", -+ .id_table = acc_hid_table, -+ .probe = acc_hid_probe, -+}; -+ -+static void acc_complete_setup_noop(struct usb_ep *ep, struct usb_request *req) -+{ -+ /* -+ * Default no-op function when nothing needs to be done for the -+ * setup request -+ */ -+} -+ -+int acc_ctrlrequest(struct usb_composite_dev *cdev, -+ const struct usb_ctrlrequest *ctrl) -+{ -+ struct acc_dev *dev = get_acc_dev(); -+ int value = -EOPNOTSUPP; -+ struct acc_hid_dev *hid; -+ int offset; -+ u8 b_requestType = ctrl->bRequestType; -+ u8 b_request = ctrl->bRequest; -+ u16 w_index = le16_to_cpu(ctrl->wIndex); -+ u16 w_value = le16_to_cpu(ctrl->wValue); -+ u16 w_length = le16_to_cpu(ctrl->wLength); -+ unsigned long flags; -+ -+ /* -+ * If instance is not created which is the case in power off charging -+ * mode, dev will be NULL. Hence return error if it is the case. -+ */ -+ if (!dev) -+ return -ENODEV; -+ -+ if (b_requestType == (USB_DIR_OUT | USB_TYPE_VENDOR)) { -+ if (b_request == ACCESSORY_START) { -+ dev->start_requested = 1; -+ schedule_delayed_work( -+ &dev->start_work, msecs_to_jiffies(10)); -+ value = 0; -+ cdev->req->complete = acc_complete_setup_noop; -+ } else if (b_request == ACCESSORY_SEND_STRING) { -+ schedule_work(&dev->sendstring_work); -+ dev->string_index = w_index; -+ cdev->gadget->ep0->driver_data = dev; -+ cdev->req->complete = acc_complete_set_string; -+ value = w_length; -+ } else if (b_request == ACCESSORY_SET_AUDIO_MODE && -+ w_index == 0 && w_length == 0) { -+ dev->audio_mode = w_value; -+ cdev->req->complete = acc_complete_setup_noop; -+ value = 0; -+ } else if (b_request == ACCESSORY_REGISTER_HID) { -+ cdev->req->complete = acc_complete_setup_noop; -+ value = acc_register_hid(dev, w_value, w_index); -+ } else if (b_request == ACCESSORY_UNREGISTER_HID) { -+ cdev->req->complete = acc_complete_setup_noop; -+ value = acc_unregister_hid(dev, w_value); -+ } else if (b_request == ACCESSORY_SET_HID_REPORT_DESC) { -+ spin_lock_irqsave(&dev->lock, flags); -+ hid = acc_hid_get(&dev->new_hid_list, w_value); -+ spin_unlock_irqrestore(&dev->lock, flags); -+ if (!hid) { -+ value = -EINVAL; -+ goto err; -+ } -+ offset = w_index; -+ if (offset != hid->report_desc_offset -+ || offset + w_length > hid->report_desc_len) { -+ value = -EINVAL; -+ goto err; -+ } -+ cdev->req->context = hid; -+ cdev->req->complete = acc_complete_set_hid_report_desc; -+ value = w_length; -+ } else if (b_request == ACCESSORY_SEND_HID_EVENT) { -+ spin_lock_irqsave(&dev->lock, flags); -+ hid = acc_hid_get(&dev->hid_list, w_value); -+ spin_unlock_irqrestore(&dev->lock, flags); -+ if (!hid) { -+ value = -EINVAL; -+ goto err; -+ } -+ cdev->req->context = hid; -+ cdev->req->complete = acc_complete_send_hid_event; -+ value = w_length; -+ } -+ } else if (b_requestType == (USB_DIR_IN | USB_TYPE_VENDOR)) { -+ if (b_request == ACCESSORY_GET_PROTOCOL) { -+ schedule_work(&dev->getprotocol_work); -+ *((u16 *)cdev->req->buf) = PROTOCOL_VERSION; -+ value = sizeof(u16); -+ cdev->req->complete = acc_complete_setup_noop; -+ /* clear any string left over from a previous session */ -+ memset(dev->manufacturer, 0, sizeof(dev->manufacturer)); -+ memset(dev->model, 0, sizeof(dev->model)); -+ memset(dev->description, 0, sizeof(dev->description)); -+ memset(dev->version, 0, sizeof(dev->version)); -+ memset(dev->uri, 0, sizeof(dev->uri)); -+ memset(dev->serial, 0, sizeof(dev->serial)); -+ dev->start_requested = 0; -+ dev->audio_mode = 0; -+ } -+ } -+ -+ if (value >= 0) { -+ cdev->req->zero = 0; -+ cdev->req->length = value; -+ value = usb_ep_queue(cdev->gadget->ep0, cdev->req, GFP_ATOMIC); -+ if (value < 0) -+ ERROR(cdev, "%s setup response queue error\n", -+ __func__); -+ } -+ -+err: -+ if (value == -EOPNOTSUPP) -+ VDBG(cdev, -+ "unknown class-specific control req " -+ "%02x.%02x v%04x i%04x l%u\n", -+ ctrl->bRequestType, ctrl->bRequest, -+ w_value, w_index, w_length); -+ put_acc_dev(dev); -+ return value; -+} -+EXPORT_SYMBOL_GPL(acc_ctrlrequest); -+ -+int acc_ctrlrequest_composite(struct usb_composite_dev *cdev, -+ const struct usb_ctrlrequest *ctrl) -+{ -+ u16 w_length = le16_to_cpu(ctrl->wLength); -+ -+ if (w_length > USB_COMP_EP0_BUFSIZ) { -+ if (ctrl->bRequestType & USB_DIR_IN) { -+ /* Cast away the const, we are going to overwrite on purpose. */ -+ __le16 *temp = (__le16 *)&ctrl->wLength; -+ -+ *temp = cpu_to_le16(USB_COMP_EP0_BUFSIZ); -+ w_length = USB_COMP_EP0_BUFSIZ; -+ } else { -+ return -EINVAL; -+ } -+ } -+ return acc_ctrlrequest(cdev, ctrl); -+} -+EXPORT_SYMBOL_GPL(acc_ctrlrequest_composite); -+ -+static int -+__acc_function_bind(struct usb_configuration *c, -+ struct usb_function *f, bool configfs) -+{ -+ struct usb_composite_dev *cdev = c->cdev; -+ struct usb_string *us; -+ struct acc_dev *dev = func_to_dev(f); -+ int id; -+ int ret; -+ -+ DBG(cdev, "acc_function_bind dev: %p\n", dev); -+ -+ if (configfs) { -+ us = usb_gstrings_attach(cdev, acc_strings, ARRAY_SIZE(acc_string_defs)); -+ if (IS_ERR(us)) -+ return PTR_ERR(us); -+ ret = us[INTERFACE_STRING_INDEX].id; -+ acc_interface_desc.iInterface = ret; -+ dev->cdev = c->cdev; -+ } -+ ret = hid_register_driver(&acc_hid_driver); -+ if (ret) -+ return ret; -+ -+ dev->start_requested = 0; -+ -+ /* allocate interface ID(s) */ -+ id = usb_interface_id(c, f); -+ if (id < 0) -+ return id; -+ acc_interface_desc.bInterfaceNumber = id; -+ -+ /* allocate endpoints */ -+ ret = create_bulk_endpoints(dev, &acc_fullspeed_in_desc, -+ &acc_fullspeed_out_desc); -+ if (ret) -+ return ret; -+ -+ /* support high speed hardware */ -+ acc_highspeed_in_desc.bEndpointAddress = -+ acc_fullspeed_in_desc.bEndpointAddress; -+ acc_highspeed_out_desc.bEndpointAddress = -+ acc_fullspeed_out_desc.bEndpointAddress; -+ -+ /* support super speed hardware */ -+ acc_superspeed_in_desc.bEndpointAddress = -+ acc_fullspeed_in_desc.bEndpointAddress; -+ acc_superspeed_out_desc.bEndpointAddress = -+ acc_fullspeed_out_desc.bEndpointAddress; -+ -+ /* support super speed plus hardware */ -+ acc_superspeedplus_in_desc.bEndpointAddress = -+ acc_fullspeed_in_desc.bEndpointAddress; -+ acc_superspeedplus_out_desc.bEndpointAddress = -+ acc_fullspeed_out_desc.bEndpointAddress; -+ -+ DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n", -+ gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", -+ f->name, dev->ep_in->name, dev->ep_out->name); -+ return 0; -+} -+ -+static int -+acc_function_bind_configfs(struct usb_configuration *c, -+ struct usb_function *f) { -+ return __acc_function_bind(c, f, true); -+} -+ -+static void -+kill_all_hid_devices(struct acc_dev *dev) -+{ -+ struct acc_hid_dev *hid; -+ struct list_head *entry, *temp; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&dev->lock, flags); -+ list_for_each_safe(entry, temp, &dev->hid_list) { -+ hid = list_entry(entry, struct acc_hid_dev, list); -+ list_del(&hid->list); -+ list_add(&hid->list, &dev->dead_hid_list); -+ } -+ list_for_each_safe(entry, temp, &dev->new_hid_list) { -+ hid = list_entry(entry, struct acc_hid_dev, list); -+ list_del(&hid->list); -+ list_add(&hid->list, &dev->dead_hid_list); -+ } -+ spin_unlock_irqrestore(&dev->lock, flags); -+ -+ schedule_work(&dev->hid_work); -+} -+ -+static void -+acc_hid_unbind(struct acc_dev *dev) -+{ -+ hid_unregister_driver(&acc_hid_driver); -+ kill_all_hid_devices(dev); -+} -+ -+static void -+acc_function_unbind(struct usb_configuration *c, struct usb_function *f) -+{ -+ struct acc_dev *dev = func_to_dev(f); -+ struct usb_request *req; -+ int i; -+ -+ dev->online = 0; /* clear online flag */ -+ wake_up(&dev->read_wq); /* unblock reads on closure */ -+ wake_up(&dev->write_wq); /* likewise for writes */ -+ -+ while ((req = req_get(dev, &dev->tx_idle))) -+ acc_request_free(req, dev->ep_in); -+ for (i = 0; i < RX_REQ_MAX; i++) { -+ acc_request_free(dev->rx_req[i], dev->ep_out); -+ dev->rx_req[i] = NULL; -+ } -+ -+ acc_hid_unbind(dev); -+} -+ -+static void acc_getprotocol_work(struct work_struct *data) -+{ -+ char *envp[2] = { "ACCESSORY=GETPROTOCOL", NULL }; -+ -+ kobject_uevent_env(&acc_device.this_device->kobj, KOBJ_CHANGE, envp); -+} -+ -+static void acc_sendstring_work(struct work_struct *data) -+{ -+ char *envp[2] = { "ACCESSORY=SENDSTRING", NULL }; -+ -+ kobject_uevent_env(&acc_device.this_device->kobj, KOBJ_CHANGE, envp); -+} -+ -+static void acc_start_work(struct work_struct *data) -+{ -+ char *envp[2] = { "ACCESSORY=START", NULL }; -+ -+ kobject_uevent_env(&acc_device.this_device->kobj, KOBJ_CHANGE, envp); -+} -+ -+static int acc_hid_init(struct acc_hid_dev *hdev) -+{ -+ struct hid_device *hid; -+ int ret; -+ -+ hid = hid_allocate_device(); -+ if (IS_ERR(hid)) -+ return PTR_ERR(hid); -+ -+ hid->ll_driver = &acc_hid_ll_driver; -+ hid->dev.parent = acc_device.this_device; -+ -+ hid->bus = BUS_USB; -+ hid->vendor = HID_ANY_ID; -+ hid->product = HID_ANY_ID; -+ hid->driver_data = hdev; -+ ret = hid_add_device(hid); -+ if (ret) { -+ pr_err("can't add hid device: %d\n", ret); -+ hid_destroy_device(hid); -+ return ret; -+ } -+ -+ hdev->hid = hid; -+ return 0; -+} -+ -+static void acc_hid_delete(struct acc_hid_dev *hid) -+{ -+ kfree(hid->report_desc); -+ kfree(hid); -+} -+ -+static void acc_hid_work(struct work_struct *data) -+{ -+ struct acc_dev *dev = get_acc_dev(); -+ struct list_head *entry, *temp; -+ struct acc_hid_dev *hid; -+ struct list_head new_list, dead_list; -+ unsigned long flags; -+ -+ if (!dev) -+ return; -+ -+ INIT_LIST_HEAD(&new_list); -+ -+ spin_lock_irqsave(&dev->lock, flags); -+ -+ /* copy hids that are ready for initialization to new_list */ -+ list_for_each_safe(entry, temp, &dev->new_hid_list) { -+ hid = list_entry(entry, struct acc_hid_dev, list); -+ if (hid->report_desc_offset == hid->report_desc_len) -+ list_move(&hid->list, &new_list); -+ } -+ -+ if (list_empty(&dev->dead_hid_list)) { -+ INIT_LIST_HEAD(&dead_list); -+ } else { -+ /* move all of dev->dead_hid_list to dead_list */ -+ dead_list.prev = dev->dead_hid_list.prev; -+ dead_list.next = dev->dead_hid_list.next; -+ dead_list.next->prev = &dead_list; -+ dead_list.prev->next = &dead_list; -+ INIT_LIST_HEAD(&dev->dead_hid_list); -+ } -+ -+ spin_unlock_irqrestore(&dev->lock, flags); -+ -+ /* register new HID devices */ -+ list_for_each_safe(entry, temp, &new_list) { -+ hid = list_entry(entry, struct acc_hid_dev, list); -+ if (acc_hid_init(hid)) { -+ pr_err("can't add HID device %p\n", hid); -+ acc_hid_delete(hid); -+ } else { -+ spin_lock_irqsave(&dev->lock, flags); -+ list_move(&hid->list, &dev->hid_list); -+ spin_unlock_irqrestore(&dev->lock, flags); -+ } -+ } -+ -+ /* remove dead HID devices */ -+ list_for_each_safe(entry, temp, &dead_list) { -+ hid = list_entry(entry, struct acc_hid_dev, list); -+ list_del(&hid->list); -+ if (hid->hid) -+ hid_destroy_device(hid->hid); -+ acc_hid_delete(hid); -+ } -+ -+ put_acc_dev(dev); -+} -+ -+static int acc_function_set_alt(struct usb_function *f, -+ unsigned intf, unsigned alt) -+{ -+ struct acc_dev *dev = func_to_dev(f); -+ struct usb_composite_dev *cdev = f->config->cdev; -+ int ret; -+ -+ DBG(cdev, "acc_function_set_alt intf: %d alt: %d\n", intf, alt); -+ -+ ret = config_ep_by_speed(cdev->gadget, f, dev->ep_in); -+ if (ret) -+ return ret; -+ -+ ret = usb_ep_enable(dev->ep_in); -+ if (ret) -+ return ret; -+ -+ ret = config_ep_by_speed(cdev->gadget, f, dev->ep_out); -+ if (ret) -+ return ret; -+ -+ ret = usb_ep_enable(dev->ep_out); -+ if (ret) { -+ usb_ep_disable(dev->ep_in); -+ return ret; -+ } -+ -+ dev->online = 1; -+ dev->disconnected = 0; /* if online then not disconnected */ -+ -+ /* readers may be blocked waiting for us to go online */ -+ wake_up(&dev->read_wq); -+ return 0; -+} -+ -+static void acc_function_disable(struct usb_function *f) -+{ -+ struct acc_dev *dev = func_to_dev(f); -+ struct usb_composite_dev *cdev = dev->cdev; -+ -+ DBG(cdev, "acc_function_disable\n"); -+ acc_set_disconnected(dev); /* this now only sets disconnected */ -+ dev->online = 0; /* so now need to clear online flag here too */ -+ usb_ep_disable(dev->ep_in); -+ usb_ep_disable(dev->ep_out); -+ -+ /* readers may be blocked waiting for us to go online */ -+ wake_up(&dev->read_wq); -+ -+ VDBG(cdev, "%s disabled\n", dev->function.name); -+} -+ -+static int acc_setup(void) -+{ -+ struct acc_dev_ref *ref = &_acc_dev_ref; -+ struct acc_dev *dev; -+ int ret; -+ -+ if (kref_read(&ref->kref)) -+ return -EBUSY; -+ -+ dev = kzalloc(sizeof(*dev), GFP_KERNEL); -+ if (!dev) -+ return -ENOMEM; -+ -+ spin_lock_init(&dev->lock); -+ init_waitqueue_head(&dev->read_wq); -+ init_waitqueue_head(&dev->write_wq); -+ atomic_set(&dev->open_excl, 0); -+ INIT_LIST_HEAD(&dev->tx_idle); -+ INIT_LIST_HEAD(&dev->hid_list); -+ INIT_LIST_HEAD(&dev->new_hid_list); -+ INIT_LIST_HEAD(&dev->dead_hid_list); -+ INIT_DELAYED_WORK(&dev->start_work, acc_start_work); -+ INIT_WORK(&dev->hid_work, acc_hid_work); -+ INIT_WORK(&dev->getprotocol_work, acc_getprotocol_work); -+ INIT_WORK(&dev->sendstring_work, acc_sendstring_work); -+ -+ dev->ref = ref; -+ if (cmpxchg_relaxed(&ref->acc_dev, NULL, dev)) { -+ ret = -EBUSY; -+ goto err_free_dev; -+ } -+ -+ ret = misc_register(&acc_device); -+ if (ret) -+ goto err_zap_ptr; -+ -+ kref_init(&ref->kref); -+ return 0; -+ -+err_zap_ptr: -+ ref->acc_dev = NULL; -+err_free_dev: -+ kfree(dev); -+ pr_err("USB accessory gadget driver failed to initialize\n"); -+ return ret; -+} -+ -+void acc_disconnect(void) -+{ -+ struct acc_dev *dev = get_acc_dev(); -+ -+ if (!dev) -+ return; -+ -+ /* unregister all HID devices if USB is disconnected */ -+ kill_all_hid_devices(dev); -+ put_acc_dev(dev); -+} -+EXPORT_SYMBOL_GPL(acc_disconnect); -+ -+static void acc_cleanup(void) -+{ -+ struct acc_dev *dev = get_acc_dev(); -+ -+ misc_deregister(&acc_device); -+ put_acc_dev(dev); -+ put_acc_dev(dev); /* Pairs with kref_init() in acc_setup() */ -+} -+static struct acc_instance *to_acc_instance(struct config_item *item) -+{ -+ return container_of(to_config_group(item), struct acc_instance, -+ func_inst.group); -+} -+ -+static void acc_attr_release(struct config_item *item) -+{ -+ struct acc_instance *fi_acc = to_acc_instance(item); -+ -+ usb_put_function_instance(&fi_acc->func_inst); -+} -+ -+static struct configfs_item_operations acc_item_ops = { -+ .release = acc_attr_release, -+}; -+ -+static struct config_item_type acc_func_type = { -+ .ct_item_ops = &acc_item_ops, -+ .ct_owner = THIS_MODULE, -+}; -+ -+static struct acc_instance *to_fi_acc(struct usb_function_instance *fi) -+{ -+ return container_of(fi, struct acc_instance, func_inst); -+} -+ -+static int acc_set_inst_name(struct usb_function_instance *fi, const char *name) -+{ -+ struct acc_instance *fi_acc; -+ char *ptr; -+ int name_len; -+ -+ name_len = strlen(name) + 1; -+ if (name_len > MAX_INST_NAME_LEN) -+ return -ENAMETOOLONG; -+ -+ ptr = kstrndup(name, name_len, GFP_KERNEL); -+ if (!ptr) -+ return -ENOMEM; -+ -+ fi_acc = to_fi_acc(fi); -+ fi_acc->name = ptr; -+ return 0; -+} -+ -+static void acc_free_inst(struct usb_function_instance *fi) -+{ -+ struct acc_instance *fi_acc; -+ -+ fi_acc = to_fi_acc(fi); -+ kfree(fi_acc->name); -+ acc_cleanup(); -+} -+ -+static struct usb_function_instance *acc_alloc_inst(void) -+{ -+ struct acc_instance *fi_acc; -+ int err; -+ -+ fi_acc = kzalloc(sizeof(*fi_acc), GFP_KERNEL); -+ if (!fi_acc) -+ return ERR_PTR(-ENOMEM); -+ fi_acc->func_inst.set_inst_name = acc_set_inst_name; -+ fi_acc->func_inst.free_func_inst = acc_free_inst; -+ -+ err = acc_setup(); -+ if (err) { -+ kfree(fi_acc); -+ return ERR_PTR(err); -+ } -+ -+ config_group_init_type_name(&fi_acc->func_inst.group, -+ "", &acc_func_type); -+ return &fi_acc->func_inst; -+} -+ -+static void acc_free(struct usb_function *f) -+{ -+ struct acc_dev *dev = func_to_dev(f); -+ -+ put_acc_dev(dev); -+} -+ -+int acc_ctrlrequest_configfs(struct usb_function *f, -+ const struct usb_ctrlrequest *ctrl) { -+ if (f->config != NULL && f->config->cdev != NULL) -+ return acc_ctrlrequest(f->config->cdev, ctrl); -+ else -+ return -1; -+} -+ -+static struct usb_function *acc_alloc(struct usb_function_instance *fi) -+{ -+ struct acc_dev *dev = get_acc_dev(); -+ -+ dev->function.name = "accessory"; -+ dev->function.strings = acc_strings, -+ dev->function.fs_descriptors = fs_acc_descs; -+ dev->function.hs_descriptors = hs_acc_descs; -+ dev->function.ss_descriptors = ss_acc_descs; -+ dev->function.ssp_descriptors = ssp_acc_descs; -+ dev->function.bind = acc_function_bind_configfs; -+ dev->function.unbind = acc_function_unbind; -+ dev->function.set_alt = acc_function_set_alt; -+ dev->function.disable = acc_function_disable; -+ dev->function.free_func = acc_free; -+ dev->function.setup = acc_ctrlrequest_configfs; -+ -+ return &dev->function; -+} -+DECLARE_USB_FUNCTION_INIT(accessory, acc_alloc_inst, acc_alloc); -+MODULE_LICENSE("GPL"); -diff --git a/include/linux/usb/f_accessory.h b/include/linux/usb/f_accessory.h -new file mode 100644 ---- /dev/null -+++ b/include/linux/usb/f_accessory.h -@@ -0,0 +1,23 @@ -+/* -+ * Gadget Function Driver for Android USB accessories -+ * -+ * Copyright (C) 2011 Google, Inc. -+ * Author: Mike Lockwood -+ * -+ * This software is licensed under the terms of the GNU General Public -+ * License version 2, as published by the Free Software Foundation, and -+ * may be copied, distributed, and modified under those terms. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ */ -+ -+#ifndef __LINUX_USB_F_ACCESSORY_H -+#define __LINUX_USB_F_ACCESSORY_H -+ -+#include -+ -+#endif /* __LINUX_USB_F_ACCESSORY_H */ -diff --git a/include/uapi/linux/usb/f_accessory.h b/include/uapi/linux/usb/f_accessory.h -new file mode 100644 ---- /dev/null -+++ b/include/uapi/linux/usb/f_accessory.h -@@ -0,0 +1,146 @@ -+/* -+ * Gadget Function Driver for Android USB accessories -+ * -+ * Copyright (C) 2011 Google, Inc. -+ * Author: Mike Lockwood -+ * -+ * This software is licensed under the terms of the GNU General Public -+ * License version 2, as published by the Free Software Foundation, and -+ * may be copied, distributed, and modified under those terms. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ */ -+ -+#ifndef _UAPI_LINUX_USB_F_ACCESSORY_H -+#define _UAPI_LINUX_USB_F_ACCESSORY_H -+ -+/* Use Google Vendor ID when in accessory mode */ -+#define USB_ACCESSORY_VENDOR_ID 0x18D1 -+ -+ -+/* Product ID to use when in accessory mode */ -+#define USB_ACCESSORY_PRODUCT_ID 0x2D00 -+ -+/* Product ID to use when in accessory mode and adb is enabled */ -+#define USB_ACCESSORY_ADB_PRODUCT_ID 0x2D01 -+ -+/* Indexes for strings sent by the host via ACCESSORY_SEND_STRING */ -+#define ACCESSORY_STRING_MANUFACTURER 0 -+#define ACCESSORY_STRING_MODEL 1 -+#define ACCESSORY_STRING_DESCRIPTION 2 -+#define ACCESSORY_STRING_VERSION 3 -+#define ACCESSORY_STRING_URI 4 -+#define ACCESSORY_STRING_SERIAL 5 -+ -+/* Control request for retrieving device's protocol version -+ * -+ * requestType: USB_DIR_IN | USB_TYPE_VENDOR -+ * request: ACCESSORY_GET_PROTOCOL -+ * value: 0 -+ * index: 0 -+ * data version number (16 bits little endian) -+ * 1 for original accessory support -+ * 2 adds HID and device to host audio support -+ */ -+#define ACCESSORY_GET_PROTOCOL 51 -+ -+/* Control request for host to send a string to the device -+ * -+ * requestType: USB_DIR_OUT | USB_TYPE_VENDOR -+ * request: ACCESSORY_SEND_STRING -+ * value: 0 -+ * index: string ID -+ * data zero terminated UTF8 string -+ * -+ * The device can later retrieve these strings via the -+ * ACCESSORY_GET_STRING_* ioctls -+ */ -+#define ACCESSORY_SEND_STRING 52 -+ -+/* Control request for starting device in accessory mode. -+ * The host sends this after setting all its strings to the device. -+ * -+ * requestType: USB_DIR_OUT | USB_TYPE_VENDOR -+ * request: ACCESSORY_START -+ * value: 0 -+ * index: 0 -+ * data none -+ */ -+#define ACCESSORY_START 53 -+ -+/* Control request for registering a HID device. -+ * Upon registering, a unique ID is sent by the accessory in the -+ * value parameter. This ID will be used for future commands for -+ * the device -+ * -+ * requestType: USB_DIR_OUT | USB_TYPE_VENDOR -+ * request: ACCESSORY_REGISTER_HID_DEVICE -+ * value: Accessory assigned ID for the HID device -+ * index: total length of the HID report descriptor -+ * data none -+ */ -+#define ACCESSORY_REGISTER_HID 54 -+ -+/* Control request for unregistering a HID device. -+ * -+ * requestType: USB_DIR_OUT | USB_TYPE_VENDOR -+ * request: ACCESSORY_REGISTER_HID -+ * value: Accessory assigned ID for the HID device -+ * index: 0 -+ * data none -+ */ -+#define ACCESSORY_UNREGISTER_HID 55 -+ -+/* Control request for sending the HID report descriptor. -+ * If the HID descriptor is longer than the endpoint zero max packet size, -+ * the descriptor will be sent in multiple ACCESSORY_SET_HID_REPORT_DESC -+ * commands. The data for the descriptor must be sent sequentially -+ * if multiple packets are needed. -+ * -+ * requestType: USB_DIR_OUT | USB_TYPE_VENDOR -+ * request: ACCESSORY_SET_HID_REPORT_DESC -+ * value: Accessory assigned ID for the HID device -+ * index: offset of data in descriptor -+ * (needed when HID descriptor is too big for one packet) -+ * data the HID report descriptor -+ */ -+#define ACCESSORY_SET_HID_REPORT_DESC 56 -+ -+/* Control request for sending HID events. -+ * -+ * requestType: USB_DIR_OUT | USB_TYPE_VENDOR -+ * request: ACCESSORY_SEND_HID_EVENT -+ * value: Accessory assigned ID for the HID device -+ * index: 0 -+ * data the HID report for the event -+ */ -+#define ACCESSORY_SEND_HID_EVENT 57 -+ -+/* Control request for setting the audio mode. -+ * -+ * requestType: USB_DIR_OUT | USB_TYPE_VENDOR -+ * request: ACCESSORY_SET_AUDIO_MODE -+ * value: 0 - no audio -+ * 1 - device to host, 44100 16-bit stereo PCM -+ * index: 0 -+ * data none -+ */ -+#define ACCESSORY_SET_AUDIO_MODE 58 -+ -+/* ioctls for retrieving strings set by the host */ -+#define ACCESSORY_GET_STRING_MANUFACTURER _IOW('M', 1, char[256]) -+#define ACCESSORY_GET_STRING_MODEL _IOW('M', 2, char[256]) -+#define ACCESSORY_GET_STRING_DESCRIPTION _IOW('M', 3, char[256]) -+#define ACCESSORY_GET_STRING_VERSION _IOW('M', 4, char[256]) -+#define ACCESSORY_GET_STRING_URI _IOW('M', 5, char[256]) -+#define ACCESSORY_GET_STRING_SERIAL _IOW('M', 6, char[256]) -+/* returns 1 if there is a start request pending */ -+#define ACCESSORY_IS_START_REQUESTED _IO('M', 7) -+/* returns audio mode (set via the ACCESSORY_SET_AUDIO_MODE control request) */ -+#define ACCESSORY_GET_AUDIO_MODE _IO('M', 8) -+ -+#endif /* _UAPI_LINUX_USB_F_ACCESSORY_H */ diff --git a/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_audio_source-New-gadget-driver-for-audio-output.patch b/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_audio_source-New-gadget-driver-for-audio-output.patch deleted file mode 100644 index 89c35d8d..00000000 --- a/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_audio_source-New-gadget-driver-for-audio-output.patch +++ /dev/null @@ -1,1150 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Mike Lockwood -Date: Fri, 11 May 2012 09:01:08 -0700 -Subject: NOUPSTREAM: ANDROID: usb: gadget: f_audio_source: New gadget driver - for audio output - -This driver presents a standard USB audio class interface to the host -and an ALSA PCM device to userspace - -[CPNOTE: 19/07/21] Lee: Should be re-written to use upstream APIs - pinged Badhri - -Bug: 78114713 -Bug: 120441124 -[badhri: f_audio_source is being migrated to userspace.] -Change-Id: If16b14a5ff27045f9cb2daaf1ae9195c5eeab7d0 -Signed-off-by: Mike Lockwood -[AmitP: Folded following android-4.9 commit changes into this patch - Parts of e27543931009 ("ANDROID: usb: gadget: Fixes and hacks to make android usb gadget compile on 3.8") - i6d9285e2574a ("ANDROID: usb: gadget: f_audio_source:replace deprecated API")] -Signed-off-by: Amit Pundir -[adelva: Folded the following changes into this patch: - ddfd0c4070c1 ("ANDROID: usb: gadget: f_audio_source: Move to USB_FUNCTION API") - a3ab81aaa19e ("ANDROID: usb: gadget: f_audio_source: Move gadget functions code") - 2095c953d894 ("ANDROID: usb: gadget: f_audio_source: change max ISO packet size") - 8671b3e53638 ("ANDROID: usb: gadget: f_audio_source: Fixed USB Audio Class Interface Descriptor") - af98f36edbe2 ("ANDROID: usb: gadget: f_audio_source: disable the CPU C-states upon playback") - a830751a338e ("CHROMIUM: usb: gadget: f_audio_source: add .free_func callback")] -Signed-off-by: Alistair Delva -Signed-off-by: Lee Jones ---- - drivers/usb/gadget/Kconfig | 12 + - drivers/usb/gadget/function/Makefile | 2 + - drivers/usb/gadget/function/f_audio_source.c | 1071 ++++++++++++++++++ - 3 files changed, 1085 insertions(+) - create mode 100644 drivers/usb/gadget/function/f_audio_source.c - -diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig ---- a/drivers/usb/gadget/Kconfig -+++ b/drivers/usb/gadget/Kconfig -@@ -223,6 +223,9 @@ config USB_F_TCM - config USB_F_ACC - tristate - -+config USB_F_AUDIO_SRC -+ tristate -+ - # this first set of drivers all depend on bulk-capable hardware. - - config USB_CONFIGFS -@@ -394,6 +397,15 @@ config USB_CONFIGFS_F_ACC - help - USB gadget Accessory support - -+config USB_CONFIGFS_F_AUDIO_SRC -+ bool "Audio Source gadget" -+ depends on USB_CONFIGFS -+ depends on SND -+ select SND_PCM -+ select USB_F_AUDIO_SRC -+ help -+ USB gadget Audio Source support -+ - config USB_CONFIGFS_F_UAC1 - bool "Audio Class 1.0" - depends on USB_CONFIGFS -diff --git a/drivers/usb/gadget/function/Makefile b/drivers/usb/gadget/function/Makefile ---- a/drivers/usb/gadget/function/Makefile -+++ b/drivers/usb/gadget/function/Makefile -@@ -54,3 +54,5 @@ usb_f_tcm-y := f_tcm.o - obj-$(CONFIG_USB_F_TCM) += usb_f_tcm.o - usb_f_accessory-y := f_accessory.o - obj-$(CONFIG_USB_F_ACC) += usb_f_accessory.o -+usb_f_audio_source-y := f_audio_source.o -+obj-$(CONFIG_USB_F_AUDIO_SRC) += usb_f_audio_source.o -diff --git a/drivers/usb/gadget/function/f_audio_source.c b/drivers/usb/gadget/function/f_audio_source.c -new file mode 100644 ---- /dev/null -+++ b/drivers/usb/gadget/function/f_audio_source.c -@@ -0,0 +1,1071 @@ -+/* -+ * Gadget Function Driver for USB audio source device -+ * -+ * Copyright (C) 2012 Google, Inc. -+ * -+ * This software is licensed under the terms of the GNU General Public -+ * License version 2, as published by the Free Software Foundation, and -+ * may be copied, distributed, and modified under those terms. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#define SAMPLE_RATE 44100 -+#define FRAMES_PER_MSEC (SAMPLE_RATE / 1000) -+ -+#define IN_EP_MAX_PACKET_SIZE 256 -+ -+/* Number of requests to allocate */ -+#define IN_EP_REQ_COUNT 4 -+ -+#define AUDIO_AC_INTERFACE 0 -+#define AUDIO_AS_INTERFACE 1 -+#define AUDIO_NUM_INTERFACES 2 -+#define MAX_INST_NAME_LEN 40 -+ -+/* B.3.1 Standard AC Interface Descriptor */ -+static struct usb_interface_descriptor ac_interface_desc = { -+ .bLength = USB_DT_INTERFACE_SIZE, -+ .bDescriptorType = USB_DT_INTERFACE, -+ .bNumEndpoints = 0, -+ .bInterfaceClass = USB_CLASS_AUDIO, -+ .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, -+}; -+ -+DECLARE_UAC_AC_HEADER_DESCRIPTOR(2); -+ -+#define UAC_DT_AC_HEADER_LENGTH UAC_DT_AC_HEADER_SIZE(AUDIO_NUM_INTERFACES) -+/* 1 input terminal, 1 output terminal and 1 feature unit */ -+#define UAC_DT_TOTAL_LENGTH (UAC_DT_AC_HEADER_LENGTH \ -+ + UAC_DT_INPUT_TERMINAL_SIZE + UAC_DT_OUTPUT_TERMINAL_SIZE \ -+ + UAC_DT_FEATURE_UNIT_SIZE(0)) -+/* B.3.2 Class-Specific AC Interface Descriptor */ -+static struct uac1_ac_header_descriptor_2 ac_header_desc = { -+ .bLength = UAC_DT_AC_HEADER_LENGTH, -+ .bDescriptorType = USB_DT_CS_INTERFACE, -+ .bDescriptorSubtype = UAC_HEADER, -+ .bcdADC = __constant_cpu_to_le16(0x0100), -+ .wTotalLength = __constant_cpu_to_le16(UAC_DT_TOTAL_LENGTH), -+ .bInCollection = AUDIO_NUM_INTERFACES, -+ .baInterfaceNr = { -+ [0] = AUDIO_AC_INTERFACE, -+ [1] = AUDIO_AS_INTERFACE, -+ } -+}; -+ -+#define INPUT_TERMINAL_ID 1 -+static struct uac_input_terminal_descriptor input_terminal_desc = { -+ .bLength = UAC_DT_INPUT_TERMINAL_SIZE, -+ .bDescriptorType = USB_DT_CS_INTERFACE, -+ .bDescriptorSubtype = UAC_INPUT_TERMINAL, -+ .bTerminalID = INPUT_TERMINAL_ID, -+ .wTerminalType = UAC_INPUT_TERMINAL_MICROPHONE, -+ .bAssocTerminal = 0, -+ .wChannelConfig = 0x3, -+}; -+ -+DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(0); -+ -+#define FEATURE_UNIT_ID 2 -+static struct uac_feature_unit_descriptor_0 feature_unit_desc = { -+ .bLength = UAC_DT_FEATURE_UNIT_SIZE(0), -+ .bDescriptorType = USB_DT_CS_INTERFACE, -+ .bDescriptorSubtype = UAC_FEATURE_UNIT, -+ .bUnitID = FEATURE_UNIT_ID, -+ .bSourceID = INPUT_TERMINAL_ID, -+ .bControlSize = 2, -+}; -+ -+#define OUTPUT_TERMINAL_ID 3 -+static struct uac1_output_terminal_descriptor output_terminal_desc = { -+ .bLength = UAC_DT_OUTPUT_TERMINAL_SIZE, -+ .bDescriptorType = USB_DT_CS_INTERFACE, -+ .bDescriptorSubtype = UAC_OUTPUT_TERMINAL, -+ .bTerminalID = OUTPUT_TERMINAL_ID, -+ .wTerminalType = UAC_TERMINAL_STREAMING, -+ .bAssocTerminal = FEATURE_UNIT_ID, -+ .bSourceID = FEATURE_UNIT_ID, -+}; -+ -+/* B.4.1 Standard AS Interface Descriptor */ -+static struct usb_interface_descriptor as_interface_alt_0_desc = { -+ .bLength = USB_DT_INTERFACE_SIZE, -+ .bDescriptorType = USB_DT_INTERFACE, -+ .bAlternateSetting = 0, -+ .bNumEndpoints = 0, -+ .bInterfaceClass = USB_CLASS_AUDIO, -+ .bInterfaceSubClass = USB_SUBCLASS_AUDIOSTREAMING, -+}; -+ -+static struct usb_interface_descriptor as_interface_alt_1_desc = { -+ .bLength = USB_DT_INTERFACE_SIZE, -+ .bDescriptorType = USB_DT_INTERFACE, -+ .bAlternateSetting = 1, -+ .bNumEndpoints = 1, -+ .bInterfaceClass = USB_CLASS_AUDIO, -+ .bInterfaceSubClass = USB_SUBCLASS_AUDIOSTREAMING, -+}; -+ -+/* B.4.2 Class-Specific AS Interface Descriptor */ -+static struct uac1_as_header_descriptor as_header_desc = { -+ .bLength = UAC_DT_AS_HEADER_SIZE, -+ .bDescriptorType = USB_DT_CS_INTERFACE, -+ .bDescriptorSubtype = UAC_AS_GENERAL, -+ .bTerminalLink = INPUT_TERMINAL_ID, -+ .bDelay = 1, -+ .wFormatTag = UAC_FORMAT_TYPE_I_PCM, -+}; -+ -+DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(1); -+ -+static struct uac_format_type_i_discrete_descriptor_1 as_type_i_desc = { -+ .bLength = UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(1), -+ .bDescriptorType = USB_DT_CS_INTERFACE, -+ .bDescriptorSubtype = UAC_FORMAT_TYPE, -+ .bFormatType = UAC_FORMAT_TYPE_I, -+ .bSubframeSize = 2, -+ .bBitResolution = 16, -+ .bSamFreqType = 1, -+}; -+ -+/* Standard ISO IN Endpoint Descriptor for highspeed */ -+static struct usb_endpoint_descriptor hs_as_in_ep_desc = { -+ .bLength = USB_DT_ENDPOINT_AUDIO_SIZE, -+ .bDescriptorType = USB_DT_ENDPOINT, -+ .bEndpointAddress = USB_DIR_IN, -+ .bmAttributes = USB_ENDPOINT_SYNC_SYNC -+ | USB_ENDPOINT_XFER_ISOC, -+ .wMaxPacketSize = __constant_cpu_to_le16(IN_EP_MAX_PACKET_SIZE), -+ .bInterval = 4, /* poll 1 per millisecond */ -+}; -+ -+/* Standard ISO IN Endpoint Descriptor for highspeed */ -+static struct usb_endpoint_descriptor fs_as_in_ep_desc = { -+ .bLength = USB_DT_ENDPOINT_AUDIO_SIZE, -+ .bDescriptorType = USB_DT_ENDPOINT, -+ .bEndpointAddress = USB_DIR_IN, -+ .bmAttributes = USB_ENDPOINT_SYNC_SYNC -+ | USB_ENDPOINT_XFER_ISOC, -+ .wMaxPacketSize = __constant_cpu_to_le16(IN_EP_MAX_PACKET_SIZE), -+ .bInterval = 1, /* poll 1 per millisecond */ -+}; -+ -+/* Class-specific AS ISO OUT Endpoint Descriptor */ -+static struct uac_iso_endpoint_descriptor as_iso_in_desc = { -+ .bLength = UAC_ISO_ENDPOINT_DESC_SIZE, -+ .bDescriptorType = USB_DT_CS_ENDPOINT, -+ .bDescriptorSubtype = UAC_EP_GENERAL, -+ .bmAttributes = 1, -+ .bLockDelayUnits = 1, -+ .wLockDelay = __constant_cpu_to_le16(1), -+}; -+ -+static struct usb_descriptor_header *hs_audio_desc[] = { -+ (struct usb_descriptor_header *)&ac_interface_desc, -+ (struct usb_descriptor_header *)&ac_header_desc, -+ -+ (struct usb_descriptor_header *)&input_terminal_desc, -+ (struct usb_descriptor_header *)&output_terminal_desc, -+ (struct usb_descriptor_header *)&feature_unit_desc, -+ -+ (struct usb_descriptor_header *)&as_interface_alt_0_desc, -+ (struct usb_descriptor_header *)&as_interface_alt_1_desc, -+ (struct usb_descriptor_header *)&as_header_desc, -+ -+ (struct usb_descriptor_header *)&as_type_i_desc, -+ -+ (struct usb_descriptor_header *)&hs_as_in_ep_desc, -+ (struct usb_descriptor_header *)&as_iso_in_desc, -+ NULL, -+}; -+ -+static struct usb_descriptor_header *fs_audio_desc[] = { -+ (struct usb_descriptor_header *)&ac_interface_desc, -+ (struct usb_descriptor_header *)&ac_header_desc, -+ -+ (struct usb_descriptor_header *)&input_terminal_desc, -+ (struct usb_descriptor_header *)&output_terminal_desc, -+ (struct usb_descriptor_header *)&feature_unit_desc, -+ -+ (struct usb_descriptor_header *)&as_interface_alt_0_desc, -+ (struct usb_descriptor_header *)&as_interface_alt_1_desc, -+ (struct usb_descriptor_header *)&as_header_desc, -+ -+ (struct usb_descriptor_header *)&as_type_i_desc, -+ -+ (struct usb_descriptor_header *)&fs_as_in_ep_desc, -+ (struct usb_descriptor_header *)&as_iso_in_desc, -+ NULL, -+}; -+ -+static struct snd_pcm_hardware audio_hw_info = { -+ .info = SNDRV_PCM_INFO_MMAP | -+ SNDRV_PCM_INFO_MMAP_VALID | -+ SNDRV_PCM_INFO_BATCH | -+ SNDRV_PCM_INFO_INTERLEAVED | -+ SNDRV_PCM_INFO_BLOCK_TRANSFER, -+ -+ .formats = SNDRV_PCM_FMTBIT_S16_LE, -+ .channels_min = 2, -+ .channels_max = 2, -+ .rate_min = SAMPLE_RATE, -+ .rate_max = SAMPLE_RATE, -+ -+ .buffer_bytes_max = 1024 * 1024, -+ .period_bytes_min = 64, -+ .period_bytes_max = 512 * 1024, -+ .periods_min = 2, -+ .periods_max = 1024, -+}; -+ -+/*-------------------------------------------------------------------------*/ -+ -+struct audio_source_config { -+ int card; -+ int device; -+}; -+ -+struct audio_dev { -+ struct usb_function func; -+ struct snd_card *card; -+ struct snd_pcm *pcm; -+ struct snd_pcm_substream *substream; -+ -+ struct list_head idle_reqs; -+ struct usb_ep *in_ep; -+ -+ spinlock_t lock; -+ -+ /* beginning, end and current position in our buffer */ -+ void *buffer_start; -+ void *buffer_end; -+ void *buffer_pos; -+ -+ /* byte size of a "period" */ -+ unsigned int period; -+ /* bytes sent since last call to snd_pcm_period_elapsed */ -+ unsigned int period_offset; -+ /* time we started playing */ -+ ktime_t start_time; -+ /* number of frames sent since start_time */ -+ s64 frames_sent; -+ struct audio_source_config *config; -+ /* for creating and issuing QoS requests */ -+ struct pm_qos_request pm_qos; -+}; -+ -+static inline struct audio_dev *func_to_audio(struct usb_function *f) -+{ -+ return container_of(f, struct audio_dev, func); -+} -+ -+/*-------------------------------------------------------------------------*/ -+ -+struct audio_source_instance { -+ struct usb_function_instance func_inst; -+ const char *name; -+ struct audio_source_config *config; -+ struct device *audio_device; -+}; -+ -+static void audio_source_attr_release(struct config_item *item); -+ -+static struct configfs_item_operations audio_source_item_ops = { -+ .release = audio_source_attr_release, -+}; -+ -+static struct config_item_type audio_source_func_type = { -+ .ct_item_ops = &audio_source_item_ops, -+ .ct_owner = THIS_MODULE, -+}; -+ -+static ssize_t audio_source_pcm_show(struct device *dev, -+ struct device_attribute *attr, char *buf); -+ -+static DEVICE_ATTR(pcm, S_IRUGO, audio_source_pcm_show, NULL); -+ -+static struct device_attribute *audio_source_function_attributes[] = { -+ &dev_attr_pcm, -+ NULL -+}; -+ -+/*--------------------------------------------------------------------------*/ -+ -+static struct usb_request *audio_request_new(struct usb_ep *ep, int buffer_size) -+{ -+ struct usb_request *req = usb_ep_alloc_request(ep, GFP_KERNEL); -+ -+ if (!req) -+ return NULL; -+ -+ req->buf = kmalloc(buffer_size, GFP_KERNEL); -+ if (!req->buf) { -+ usb_ep_free_request(ep, req); -+ return NULL; -+ } -+ req->length = buffer_size; -+ return req; -+} -+ -+static void audio_request_free(struct usb_request *req, struct usb_ep *ep) -+{ -+ if (req) { -+ kfree(req->buf); -+ usb_ep_free_request(ep, req); -+ } -+} -+ -+static void audio_req_put(struct audio_dev *audio, struct usb_request *req) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave(&audio->lock, flags); -+ list_add_tail(&req->list, &audio->idle_reqs); -+ spin_unlock_irqrestore(&audio->lock, flags); -+} -+ -+static struct usb_request *audio_req_get(struct audio_dev *audio) -+{ -+ unsigned long flags; -+ struct usb_request *req; -+ -+ spin_lock_irqsave(&audio->lock, flags); -+ if (list_empty(&audio->idle_reqs)) { -+ req = 0; -+ } else { -+ req = list_first_entry(&audio->idle_reqs, struct usb_request, -+ list); -+ list_del(&req->list); -+ } -+ spin_unlock_irqrestore(&audio->lock, flags); -+ return req; -+} -+ -+/* send the appropriate number of packets to match our bitrate */ -+static void audio_send(struct audio_dev *audio) -+{ -+ struct snd_pcm_runtime *runtime; -+ struct usb_request *req; -+ int length, length1, length2, ret; -+ s64 msecs; -+ s64 frames; -+ ktime_t now; -+ -+ /* audio->substream will be null if we have been closed */ -+ if (!audio->substream) -+ return; -+ /* audio->buffer_pos will be null if we have been stopped */ -+ if (!audio->buffer_pos) -+ return; -+ -+ runtime = audio->substream->runtime; -+ -+ /* compute number of frames to send */ -+ now = ktime_get(); -+ msecs = div_s64((ktime_to_ns(now) - ktime_to_ns(audio->start_time)), -+ 1000000); -+ frames = div_s64((msecs * SAMPLE_RATE), 1000); -+ -+ /* Readjust our frames_sent if we fall too far behind. -+ * If we get too far behind it is better to drop some frames than -+ * to keep sending data too fast in an attempt to catch up. -+ */ -+ if (frames - audio->frames_sent > 10 * FRAMES_PER_MSEC) -+ audio->frames_sent = frames - FRAMES_PER_MSEC; -+ -+ frames -= audio->frames_sent; -+ -+ /* We need to send something to keep the pipeline going */ -+ if (frames <= 0) -+ frames = FRAMES_PER_MSEC; -+ -+ while (frames > 0) { -+ req = audio_req_get(audio); -+ if (!req) -+ break; -+ -+ length = frames_to_bytes(runtime, frames); -+ if (length > IN_EP_MAX_PACKET_SIZE) -+ length = IN_EP_MAX_PACKET_SIZE; -+ -+ if (audio->buffer_pos + length > audio->buffer_end) -+ length1 = audio->buffer_end - audio->buffer_pos; -+ else -+ length1 = length; -+ memcpy(req->buf, audio->buffer_pos, length1); -+ if (length1 < length) { -+ /* Wrap around and copy remaining length -+ * at beginning of buffer. -+ */ -+ length2 = length - length1; -+ memcpy(req->buf + length1, audio->buffer_start, -+ length2); -+ audio->buffer_pos = audio->buffer_start + length2; -+ } else { -+ audio->buffer_pos += length1; -+ if (audio->buffer_pos >= audio->buffer_end) -+ audio->buffer_pos = audio->buffer_start; -+ } -+ -+ req->length = length; -+ ret = usb_ep_queue(audio->in_ep, req, GFP_ATOMIC); -+ if (ret < 0) { -+ pr_err("usb_ep_queue failed ret: %d\n", ret); -+ audio_req_put(audio, req); -+ break; -+ } -+ -+ frames -= bytes_to_frames(runtime, length); -+ audio->frames_sent += bytes_to_frames(runtime, length); -+ } -+} -+ -+static void audio_control_complete(struct usb_ep *ep, struct usb_request *req) -+{ -+ /* nothing to do here */ -+} -+ -+static void audio_data_complete(struct usb_ep *ep, struct usb_request *req) -+{ -+ struct audio_dev *audio = req->context; -+ -+ pr_debug("audio_data_complete req->status %d req->actual %d\n", -+ req->status, req->actual); -+ -+ audio_req_put(audio, req); -+ -+ if (!audio->buffer_start || req->status) -+ return; -+ -+ audio->period_offset += req->actual; -+ if (audio->period_offset >= audio->period) { -+ snd_pcm_period_elapsed(audio->substream); -+ audio->period_offset = 0; -+ } -+ audio_send(audio); -+} -+ -+static int audio_set_endpoint_req(struct usb_function *f, -+ const struct usb_ctrlrequest *ctrl) -+{ -+ int value = -EOPNOTSUPP; -+ u16 ep = le16_to_cpu(ctrl->wIndex); -+ u16 len = le16_to_cpu(ctrl->wLength); -+ u16 w_value = le16_to_cpu(ctrl->wValue); -+ -+ pr_debug("bRequest 0x%x, w_value 0x%04x, len %d, endpoint %d\n", -+ ctrl->bRequest, w_value, len, ep); -+ -+ switch (ctrl->bRequest) { -+ case UAC_SET_CUR: -+ case UAC_SET_MIN: -+ case UAC_SET_MAX: -+ case UAC_SET_RES: -+ value = len; -+ break; -+ default: -+ break; -+ } -+ -+ return value; -+} -+ -+static int audio_get_endpoint_req(struct usb_function *f, -+ const struct usb_ctrlrequest *ctrl) -+{ -+ struct usb_composite_dev *cdev = f->config->cdev; -+ int value = -EOPNOTSUPP; -+ u8 ep = ((le16_to_cpu(ctrl->wIndex) >> 8) & 0xFF); -+ u16 len = le16_to_cpu(ctrl->wLength); -+ u16 w_value = le16_to_cpu(ctrl->wValue); -+ u8 *buf = cdev->req->buf; -+ -+ pr_debug("bRequest 0x%x, w_value 0x%04x, len %d, endpoint %d\n", -+ ctrl->bRequest, w_value, len, ep); -+ -+ if (w_value == UAC_EP_CS_ATTR_SAMPLE_RATE << 8) { -+ switch (ctrl->bRequest) { -+ case UAC_GET_CUR: -+ case UAC_GET_MIN: -+ case UAC_GET_MAX: -+ case UAC_GET_RES: -+ /* return our sample rate */ -+ buf[0] = (u8)SAMPLE_RATE; -+ buf[1] = (u8)(SAMPLE_RATE >> 8); -+ buf[2] = (u8)(SAMPLE_RATE >> 16); -+ value = 3; -+ break; -+ default: -+ break; -+ } -+ } -+ -+ return value; -+} -+ -+static int -+audio_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) -+{ -+ struct usb_composite_dev *cdev = f->config->cdev; -+ struct usb_request *req = cdev->req; -+ int value = -EOPNOTSUPP; -+ u16 w_index = le16_to_cpu(ctrl->wIndex); -+ u16 w_value = le16_to_cpu(ctrl->wValue); -+ u16 w_length = le16_to_cpu(ctrl->wLength); -+ -+ /* composite driver infrastructure handles everything; interface -+ * activation uses set_alt(). -+ */ -+ switch (ctrl->bRequestType) { -+ case USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_ENDPOINT: -+ value = audio_set_endpoint_req(f, ctrl); -+ break; -+ -+ case USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_ENDPOINT: -+ value = audio_get_endpoint_req(f, ctrl); -+ break; -+ } -+ -+ /* respond with data transfer or status phase? */ -+ if (value >= 0) { -+ pr_debug("audio req%02x.%02x v%04x i%04x l%d\n", -+ ctrl->bRequestType, ctrl->bRequest, -+ w_value, w_index, w_length); -+ req->zero = 0; -+ req->length = value; -+ req->complete = audio_control_complete; -+ value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC); -+ if (value < 0) -+ pr_err("audio response on err %d\n", value); -+ } -+ -+ /* device either stalls (value < 0) or reports success */ -+ return value; -+} -+ -+static int audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt) -+{ -+ struct audio_dev *audio = func_to_audio(f); -+ struct usb_composite_dev *cdev = f->config->cdev; -+ int ret; -+ -+ pr_debug("audio_set_alt intf %d, alt %d\n", intf, alt); -+ -+ ret = config_ep_by_speed(cdev->gadget, f, audio->in_ep); -+ if (ret) -+ return ret; -+ -+ usb_ep_enable(audio->in_ep); -+ return 0; -+} -+ -+static void audio_disable(struct usb_function *f) -+{ -+ struct audio_dev *audio = func_to_audio(f); -+ -+ pr_debug("audio_disable\n"); -+ usb_ep_disable(audio->in_ep); -+} -+ -+static void audio_free_func(struct usb_function *f) -+{ -+ /* no-op */ -+} -+ -+/*-------------------------------------------------------------------------*/ -+ -+static void audio_build_desc(struct audio_dev *audio) -+{ -+ u8 *sam_freq; -+ int rate; -+ -+ /* Set channel numbers */ -+ input_terminal_desc.bNrChannels = 2; -+ as_type_i_desc.bNrChannels = 2; -+ -+ /* Set sample rates */ -+ rate = SAMPLE_RATE; -+ sam_freq = as_type_i_desc.tSamFreq[0]; -+ memcpy(sam_freq, &rate, 3); -+} -+ -+ -+static int snd_card_setup(struct usb_configuration *c, -+ struct audio_source_config *config); -+static struct audio_source_instance *to_fi_audio_source( -+ const struct usb_function_instance *fi); -+ -+ -+/* audio function driver setup/binding */ -+static int -+audio_bind(struct usb_configuration *c, struct usb_function *f) -+{ -+ struct usb_composite_dev *cdev = c->cdev; -+ struct audio_dev *audio = func_to_audio(f); -+ int status; -+ struct usb_ep *ep; -+ struct usb_request *req; -+ int i; -+ int err; -+ -+ if (IS_ENABLED(CONFIG_USB_CONFIGFS)) { -+ struct audio_source_instance *fi_audio = -+ to_fi_audio_source(f->fi); -+ struct audio_source_config *config = -+ fi_audio->config; -+ -+ err = snd_card_setup(c, config); -+ if (err) -+ return err; -+ } -+ -+ audio_build_desc(audio); -+ -+ /* allocate instance-specific interface IDs, and patch descriptors */ -+ status = usb_interface_id(c, f); -+ if (status < 0) -+ goto fail; -+ ac_interface_desc.bInterfaceNumber = status; -+ -+ /* AUDIO_AC_INTERFACE */ -+ ac_header_desc.baInterfaceNr[0] = status; -+ -+ status = usb_interface_id(c, f); -+ if (status < 0) -+ goto fail; -+ as_interface_alt_0_desc.bInterfaceNumber = status; -+ as_interface_alt_1_desc.bInterfaceNumber = status; -+ -+ /* AUDIO_AS_INTERFACE */ -+ ac_header_desc.baInterfaceNr[1] = status; -+ -+ status = -ENODEV; -+ -+ /* allocate our endpoint */ -+ ep = usb_ep_autoconfig(cdev->gadget, &fs_as_in_ep_desc); -+ if (!ep) -+ goto fail; -+ audio->in_ep = ep; -+ ep->driver_data = audio; /* claim */ -+ -+ if (gadget_is_dualspeed(c->cdev->gadget)) -+ hs_as_in_ep_desc.bEndpointAddress = -+ fs_as_in_ep_desc.bEndpointAddress; -+ -+ f->fs_descriptors = fs_audio_desc; -+ f->hs_descriptors = hs_audio_desc; -+ -+ for (i = 0, status = 0; i < IN_EP_REQ_COUNT && status == 0; i++) { -+ req = audio_request_new(ep, IN_EP_MAX_PACKET_SIZE); -+ if (req) { -+ req->context = audio; -+ req->complete = audio_data_complete; -+ audio_req_put(audio, req); -+ } else -+ status = -ENOMEM; -+ } -+ -+fail: -+ return status; -+} -+ -+static void -+audio_unbind(struct usb_configuration *c, struct usb_function *f) -+{ -+ struct audio_dev *audio = func_to_audio(f); -+ struct usb_request *req; -+ -+ while ((req = audio_req_get(audio))) -+ audio_request_free(req, audio->in_ep); -+ -+ snd_card_free_when_closed(audio->card); -+ audio->card = NULL; -+ audio->pcm = NULL; -+ audio->substream = NULL; -+ audio->in_ep = NULL; -+ -+ if (IS_ENABLED(CONFIG_USB_CONFIGFS)) { -+ struct audio_source_instance *fi_audio = -+ to_fi_audio_source(f->fi); -+ struct audio_source_config *config = -+ fi_audio->config; -+ -+ config->card = -1; -+ config->device = -1; -+ } -+} -+ -+static void audio_pcm_playback_start(struct audio_dev *audio) -+{ -+ audio->start_time = ktime_get(); -+ audio->frames_sent = 0; -+ audio_send(audio); -+} -+ -+static void audio_pcm_playback_stop(struct audio_dev *audio) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave(&audio->lock, flags); -+ audio->buffer_start = 0; -+ audio->buffer_end = 0; -+ audio->buffer_pos = 0; -+ spin_unlock_irqrestore(&audio->lock, flags); -+} -+ -+static int audio_pcm_open(struct snd_pcm_substream *substream) -+{ -+ struct snd_pcm_runtime *runtime = substream->runtime; -+ struct audio_dev *audio = substream->private_data; -+ -+ runtime->private_data = audio; -+ runtime->hw = audio_hw_info; -+ snd_pcm_limit_hw_rates(runtime); -+ runtime->hw.channels_max = 2; -+ -+ audio->substream = substream; -+ -+ /* Add the QoS request and set the latency to 0 */ -+ cpu_latency_qos_add_request(&audio->pm_qos, 0); -+ -+ return 0; -+} -+ -+static int audio_pcm_close(struct snd_pcm_substream *substream) -+{ -+ struct audio_dev *audio = substream->private_data; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&audio->lock, flags); -+ -+ /* Remove the QoS request */ -+ cpu_latency_qos_remove_request(&audio->pm_qos); -+ -+ audio->substream = NULL; -+ spin_unlock_irqrestore(&audio->lock, flags); -+ -+ return 0; -+} -+ -+static int audio_pcm_hw_params(struct snd_pcm_substream *substream, -+ struct snd_pcm_hw_params *params) -+{ -+ unsigned int channels = params_channels(params); -+ unsigned int rate = params_rate(params); -+ -+ if (rate != SAMPLE_RATE) -+ return -EINVAL; -+ if (channels != 2) -+ return -EINVAL; -+ -+ return snd_pcm_lib_alloc_vmalloc_buffer(substream, -+ params_buffer_bytes(params)); -+} -+ -+static int audio_pcm_hw_free(struct snd_pcm_substream *substream) -+{ -+ return snd_pcm_lib_free_vmalloc_buffer(substream); -+} -+ -+static int audio_pcm_prepare(struct snd_pcm_substream *substream) -+{ -+ struct snd_pcm_runtime *runtime = substream->runtime; -+ struct audio_dev *audio = runtime->private_data; -+ -+ audio->period = snd_pcm_lib_period_bytes(substream); -+ audio->period_offset = 0; -+ audio->buffer_start = runtime->dma_area; -+ audio->buffer_end = audio->buffer_start -+ + snd_pcm_lib_buffer_bytes(substream); -+ audio->buffer_pos = audio->buffer_start; -+ -+ return 0; -+} -+ -+static snd_pcm_uframes_t audio_pcm_pointer(struct snd_pcm_substream *substream) -+{ -+ struct snd_pcm_runtime *runtime = substream->runtime; -+ struct audio_dev *audio = runtime->private_data; -+ ssize_t bytes = audio->buffer_pos - audio->buffer_start; -+ -+ /* return offset of next frame to fill in our buffer */ -+ return bytes_to_frames(runtime, bytes); -+} -+ -+static int audio_pcm_playback_trigger(struct snd_pcm_substream *substream, -+ int cmd) -+{ -+ struct audio_dev *audio = substream->runtime->private_data; -+ int ret = 0; -+ -+ switch (cmd) { -+ case SNDRV_PCM_TRIGGER_START: -+ case SNDRV_PCM_TRIGGER_RESUME: -+ audio_pcm_playback_start(audio); -+ break; -+ -+ case SNDRV_PCM_TRIGGER_STOP: -+ case SNDRV_PCM_TRIGGER_SUSPEND: -+ audio_pcm_playback_stop(audio); -+ break; -+ -+ default: -+ ret = -EINVAL; -+ } -+ -+ return ret; -+} -+ -+static struct audio_dev _audio_dev = { -+ .func = { -+ .name = "audio_source", -+ .bind = audio_bind, -+ .unbind = audio_unbind, -+ .set_alt = audio_set_alt, -+ .setup = audio_setup, -+ .disable = audio_disable, -+ .free_func = audio_free_func, -+ }, -+ .lock = __SPIN_LOCK_UNLOCKED(_audio_dev.lock), -+ .idle_reqs = LIST_HEAD_INIT(_audio_dev.idle_reqs), -+}; -+ -+static struct snd_pcm_ops audio_playback_ops = { -+ .open = audio_pcm_open, -+ .close = audio_pcm_close, -+ .ioctl = snd_pcm_lib_ioctl, -+ .hw_params = audio_pcm_hw_params, -+ .hw_free = audio_pcm_hw_free, -+ .prepare = audio_pcm_prepare, -+ .trigger = audio_pcm_playback_trigger, -+ .pointer = audio_pcm_pointer, -+}; -+ -+int audio_source_bind_config(struct usb_configuration *c, -+ struct audio_source_config *config) -+{ -+ struct audio_dev *audio; -+ int err; -+ -+ config->card = -1; -+ config->device = -1; -+ -+ audio = &_audio_dev; -+ -+ err = snd_card_setup(c, config); -+ if (err) -+ return err; -+ -+ err = usb_add_function(c, &audio->func); -+ if (err) -+ goto add_fail; -+ -+ return 0; -+ -+add_fail: -+ snd_card_free(audio->card); -+ return err; -+} -+ -+static int snd_card_setup(struct usb_configuration *c, -+ struct audio_source_config *config) -+{ -+ struct audio_dev *audio; -+ struct snd_card *card; -+ struct snd_pcm *pcm; -+ int err; -+ -+ audio = &_audio_dev; -+ -+ err = snd_card_new(&c->cdev->gadget->dev, -+ SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, -+ THIS_MODULE, 0, &card); -+ if (err) -+ return err; -+ -+ err = snd_pcm_new(card, "USB audio source", 0, 1, 0, &pcm); -+ if (err) -+ goto pcm_fail; -+ -+ pcm->private_data = audio; -+ pcm->info_flags = 0; -+ audio->pcm = pcm; -+ -+ strlcpy(pcm->name, "USB gadget audio", sizeof(pcm->name)); -+ -+ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &audio_playback_ops); -+ snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, -+ NULL, 0, 64 * 1024); -+ -+ strlcpy(card->driver, "audio_source", sizeof(card->driver)); -+ strlcpy(card->shortname, card->driver, sizeof(card->shortname)); -+ strlcpy(card->longname, "USB accessory audio source", -+ sizeof(card->longname)); -+ -+ err = snd_card_register(card); -+ if (err) -+ goto register_fail; -+ -+ config->card = pcm->card->number; -+ config->device = pcm->device; -+ audio->card = card; -+ return 0; -+ -+register_fail: -+pcm_fail: -+ snd_card_free(audio->card); -+ return err; -+} -+ -+static struct audio_source_instance *to_audio_source_instance( -+ struct config_item *item) -+{ -+ return container_of(to_config_group(item), struct audio_source_instance, -+ func_inst.group); -+} -+ -+static struct audio_source_instance *to_fi_audio_source( -+ const struct usb_function_instance *fi) -+{ -+ return container_of(fi, struct audio_source_instance, func_inst); -+} -+ -+static void audio_source_attr_release(struct config_item *item) -+{ -+ struct audio_source_instance *fi_audio = to_audio_source_instance(item); -+ -+ usb_put_function_instance(&fi_audio->func_inst); -+} -+ -+static int audio_source_set_inst_name(struct usb_function_instance *fi, -+ const char *name) -+{ -+ struct audio_source_instance *fi_audio; -+ char *ptr; -+ int name_len; -+ -+ name_len = strlen(name) + 1; -+ if (name_len > MAX_INST_NAME_LEN) -+ return -ENAMETOOLONG; -+ -+ ptr = kstrndup(name, name_len, GFP_KERNEL); -+ if (!ptr) -+ return -ENOMEM; -+ -+ fi_audio = to_fi_audio_source(fi); -+ fi_audio->name = ptr; -+ -+ return 0; -+} -+ -+static void audio_source_free_inst(struct usb_function_instance *fi) -+{ -+ struct audio_source_instance *fi_audio; -+ -+ fi_audio = to_fi_audio_source(fi); -+ device_destroy(fi_audio->audio_device->class, -+ fi_audio->audio_device->devt); -+ kfree(fi_audio->name); -+ kfree(fi_audio->config); -+} -+ -+static ssize_t audio_source_pcm_show(struct device *dev, -+ struct device_attribute *attr, char *buf) -+{ -+ struct audio_source_instance *fi_audio = dev_get_drvdata(dev); -+ struct audio_source_config *config = fi_audio->config; -+ -+ /* print PCM card and device numbers */ -+ return sprintf(buf, "%d %d\n", config->card, config->device); -+} -+ -+struct device *create_function_device(char *name); -+ -+static struct usb_function_instance *audio_source_alloc_inst(void) -+{ -+ struct audio_source_instance *fi_audio; -+ struct device_attribute **attrs; -+ struct device_attribute *attr; -+ struct device *dev; -+ void *err_ptr; -+ int err = 0; -+ -+ fi_audio = kzalloc(sizeof(*fi_audio), GFP_KERNEL); -+ if (!fi_audio) -+ return ERR_PTR(-ENOMEM); -+ -+ fi_audio->func_inst.set_inst_name = audio_source_set_inst_name; -+ fi_audio->func_inst.free_func_inst = audio_source_free_inst; -+ -+ fi_audio->config = kzalloc(sizeof(struct audio_source_config), -+ GFP_KERNEL); -+ if (!fi_audio->config) { -+ err_ptr = ERR_PTR(-ENOMEM); -+ goto fail_audio; -+ } -+ -+ config_group_init_type_name(&fi_audio->func_inst.group, "", -+ &audio_source_func_type); -+ dev = create_function_device("f_audio_source"); -+ -+ if (IS_ERR(dev)) { -+ err_ptr = dev; -+ goto fail_audio_config; -+ } -+ -+ fi_audio->config->card = -1; -+ fi_audio->config->device = -1; -+ fi_audio->audio_device = dev; -+ -+ attrs = audio_source_function_attributes; -+ if (attrs) { -+ while ((attr = *attrs++) && !err) -+ err = device_create_file(dev, attr); -+ if (err) { -+ err_ptr = ERR_PTR(-EINVAL); -+ goto fail_device; -+ } -+ } -+ -+ dev_set_drvdata(dev, fi_audio); -+ _audio_dev.config = fi_audio->config; -+ -+ return &fi_audio->func_inst; -+ -+fail_device: -+ device_destroy(dev->class, dev->devt); -+fail_audio_config: -+ kfree(fi_audio->config); -+fail_audio: -+ kfree(fi_audio); -+ return err_ptr; -+ -+} -+ -+static struct usb_function *audio_source_alloc(struct usb_function_instance *fi) -+{ -+ return &_audio_dev.func; -+} -+ -+DECLARE_USB_FUNCTION_INIT(audio_source, audio_source_alloc_inst, -+ audio_source_alloc); -+MODULE_LICENSE("GPL"); diff --git a/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_midi-create-F_midi-device.patch b/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_midi-create-F_midi-device.patch deleted file mode 100644 index ae8af3c0..00000000 --- a/android-mainline/NOUPSTREAM-ANDROID-usb-gadget-f_midi-create-F_midi-device.patch +++ /dev/null @@ -1,117 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Badhri Jagan Sridharan -Date: Wed, 2 Sep 2015 22:49:10 -0700 -Subject: NOUPSTREAM: ANDROID: usb: gadget: f_midi: create F_midi device - -Android frameworks relies on the alsa -config reported by the f_midi device. - -[CPNOTE: 19/07/21] Lee: Should be re-written to use upstream APIs - pinged Badhri - -Bug: 111003288 -Bug: 120441124 -Change-Id: I0695e00b166fd953f50acea93802245b0d5a5240 -[badhri: The framework should be moved away from this] -Signed-off-by: Badhri Jagan Sridharan -Signed-off-by: Lee Jones ---- - drivers/usb/gadget/function/f_midi.c | 66 ++++++++++++++++++++++++++++ - 1 file changed, 66 insertions(+) - -diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c ---- a/drivers/usb/gadget/function/f_midi.c -+++ b/drivers/usb/gadget/function/f_midi.c -@@ -1258,6 +1258,65 @@ static void f_midi_free_inst(struct usb_function_instance *f) - } - } - -+#ifdef CONFIG_USB_CONFIGFS_UEVENT -+extern struct device *create_function_device(char *name); -+static ssize_t alsa_show(struct device *dev, -+ struct device_attribute *attr, char *buf) -+{ -+ struct usb_function_instance *fi_midi = dev_get_drvdata(dev); -+ struct f_midi *midi; -+ -+ if (!fi_midi->f) -+ dev_warn(dev, "f_midi: function not set\n"); -+ -+ if (fi_midi && fi_midi->f) { -+ midi = func_to_midi(fi_midi->f); -+ if (midi->rmidi && midi->card && midi->rmidi->card) -+ return sprintf(buf, "%d %d\n", -+ midi->rmidi->card->number, midi->rmidi->device); -+ } -+ -+ /* print PCM card and device numbers */ -+ return sprintf(buf, "%d %d\n", -1, -1); -+} -+ -+static DEVICE_ATTR(alsa, S_IRUGO, alsa_show, NULL); -+ -+static struct device_attribute *alsa_function_attributes[] = { -+ &dev_attr_alsa, -+ NULL -+}; -+ -+static int create_alsa_device(struct usb_function_instance *fi) -+{ -+ struct device *dev; -+ struct device_attribute **attrs; -+ struct device_attribute *attr; -+ int err = 0; -+ -+ dev = create_function_device("f_midi"); -+ if (IS_ERR(dev)) -+ return PTR_ERR(dev); -+ -+ attrs = alsa_function_attributes; -+ if (attrs) { -+ while ((attr = *attrs++) && !err) -+ err = device_create_file(dev, attr); -+ if (err) { -+ device_destroy(dev->class, dev->devt); -+ return -EINVAL; -+ } -+ } -+ dev_set_drvdata(dev, fi); -+ return 0; -+} -+#else -+static int create_alsa_device(struct usb_function_instance *fi) -+{ -+ return 0; -+} -+#endif -+ - static struct usb_function_instance *f_midi_alloc_inst(void) - { - struct f_midi_opts *opts; -@@ -1276,6 +1335,11 @@ static struct usb_function_instance *f_midi_alloc_inst(void) - opts->out_ports = 1; - opts->refcnt = 1; - -+ if (create_alsa_device(&opts->func_inst)) { -+ kfree(opts); -+ return ERR_PTR(-ENODEV); -+ } -+ - config_group_init_type_name(&opts->func_inst.group, "", - &midi_func_type); - -@@ -1296,6 +1360,7 @@ static void f_midi_free(struct usb_function *f) - kfifo_free(&midi->in_req_fifo); - kfree(midi); - free = true; -+ opts->func_inst.f = NULL; - } - mutex_unlock(&opts->lock); - -@@ -1383,6 +1448,7 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi) - midi->func.disable = f_midi_disable; - midi->func.free_func = f_midi_free; - -+ fi->f = &midi->func; - return &midi->func; - - midi_free: diff --git a/android-mainline/TODO-LEE-ANDROID-Revert-usb-typec-tcpm-not-sink-vbus-if-operational-current-is-0mA.patch b/android-mainline/TODO-LEE-ANDROID-Revert-usb-typec-tcpm-not-sink-vbus-if-operational-current-is-0mA.patch new file mode 100644 index 00000000..d166875e --- /dev/null +++ b/android-mainline/TODO-LEE-ANDROID-Revert-usb-typec-tcpm-not-sink-vbus-if-operational-current-is-0mA.patch @@ -0,0 +1,49 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andr=C3=A9=20Draszik?= +Date: Wed, 25 Oct 2023 14:26:51 +0100 +Subject: TODO: LEE: ANDROID: Revert "usb: typec: tcpm: not sink vbus if + operational current is 0mA" +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This reverts commit 803b1c8a0cea58cccde16eba31d285956f4c920c. + +Prevents Pixel from charging. Revert while we investigate the issue. + +[CPNOTE: 24/01/29] Lee: Greg reverted some of this, but leaves some diff + +Test: adb shell cat /sys/class/power_supply/battery/status +Bug: 307718635 +Change-Id: I9e8c6c62aac25cf41ac37c1d6bda696d8ecaf4aa +Signed-off-by: André Draszik + +ANDROID: bring back typec charger changes. + +This file was originally touched to revert an upstream change that broke +the Pixel from charging, but it has now been resolved properly upstream +and the real fix will come in through the USB tree correctly. Revert +the out-of-tree changes to allow the merge to happen properly. + +Bug: 307718635 +Bug: 298207935 +Cc: André Draszik +Change-Id: Icaba3965ad54d2eecf5a851520613b35770dccee +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/typec/tcpm/tcpm.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c +--- a/drivers/usb/typec/tcpm/tcpm.c ++++ b/drivers/usb/typec/tcpm/tcpm.c +@@ -4856,7 +4856,8 @@ static void run_state_machine(struct tcpm_port *port) + break; + case PORT_RESET: + tcpm_reset_port(port); +- tcpm_set_cc(port, TYPEC_CC_OPEN); ++ tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ? ++ TYPEC_CC_RD : tcpm_rp_cc(port)); + tcpm_set_state(port, PORT_RESET_WAIT_OFF, + PD_T_ERROR_RECOVERY); + break; diff --git a/android-mainline/_____ANNOTATION-Android-exports_____.patch b/android-mainline/_____ANNOTATION-Android-exports_____.patch index 37cb5569..04cf132d 100644 --- a/android-mainline/_____ANNOTATION-Android-exports_____.patch +++ b/android-mainline/_____ANNOTATION-Android-exports_____.patch @@ -13,7 +13,7 @@ Signed-off-by: Lee Jones diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -23,3 +23,4 @@ Incremental filesystem +@@ -22,3 +22,4 @@ Incremental filesystem networking changes hardware-wrapped key support Android vendor hooks diff --git a/android-mainline/_____ANNOTATION-Android-kconfigs-and-build-scripts_____.patch b/android-mainline/_____ANNOTATION-Android-kconfigs-and-build-scripts_____.patch index 9d32409a..159ab542 100644 --- a/android-mainline/_____ANNOTATION-Android-kconfigs-and-build-scripts_____.patch +++ b/android-mainline/_____ANNOTATION-Android-kconfigs-and-build-scripts_____.patch @@ -17,7 +17,7 @@ Change-Id: I088def2072fa0e3e1c579610bc7c9d97d52fb06e diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -24,3 +24,4 @@ networking changes +@@ -23,3 +23,4 @@ networking changes hardware-wrapped key support Android vendor hooks Android exports diff --git a/android-mainline/_____ANNOTATION-Android-vendor-hooks_____.patch b/android-mainline/_____ANNOTATION-Android-vendor-hooks_____.patch index a07162d5..472731f5 100644 --- a/android-mainline/_____ANNOTATION-Android-vendor-hooks_____.patch +++ b/android-mainline/_____ANNOTATION-Android-vendor-hooks_____.patch @@ -13,7 +13,7 @@ Change-Id: I8ffacc5d3e8b7181bb78b0c10ecd0a7baf4d4e33 diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -22,3 +22,4 @@ filesystem changes +@@ -21,3 +21,4 @@ filesystem changes Incremental filesystem networking changes hardware-wrapped key support diff --git a/android-mainline/_____ANNOTATION-Incremental-filesystem_____.patch b/android-mainline/_____ANNOTATION-Incremental-filesystem_____.patch index a491d313..c8096dbf 100644 --- a/android-mainline/_____ANNOTATION-Incremental-filesystem_____.patch +++ b/android-mainline/_____ANNOTATION-Incremental-filesystem_____.patch @@ -13,7 +13,7 @@ Change-Id: I7d0fa7bc25a9fa37fe7f5f7d201f4af2c5028db8 diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -19,3 +19,4 @@ UFS driver changes +@@ -18,3 +18,4 @@ UFS driver changes block changes device-mapper changes filesystem changes diff --git a/android-mainline/_____ANNOTATION-UFS-driver-changes_____.patch b/android-mainline/_____ANNOTATION-UFS-driver-changes_____.patch index 74df2b14..5e3ebd7c 100644 --- a/android-mainline/_____ANNOTATION-UFS-driver-changes_____.patch +++ b/android-mainline/_____ANNOTATION-UFS-driver-changes_____.patch @@ -13,8 +13,8 @@ Change-Id: I1fc1f4ff872e675ffff63e0936577e128b7c43cd diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -15,3 +15,4 @@ tty changes - USB changes +@@ -14,3 +14,4 @@ driver framework and misc driver changes + tty changes graphics changes sound changes +UFS driver changes diff --git a/android-mainline/_____ANNOTATION-USB-changes_____.patch b/android-mainline/_____ANNOTATION-USB-changes_____.patch deleted file mode 100644 index 4c8beedb..00000000 --- a/android-mainline/_____ANNOTATION-USB-changes_____.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Eric Biggers -Date: Wed, 12 Aug 2020 14:01:11 -0700 -Subject: _____ANNOTATION: USB changes_____ - -Signed-off-by: Eric Biggers -Signed-off-by: Lee Jones -Change-Id: I06aaa4d0ca2e908de0bb039c1db4c7ef9781bd17 ---- - ANNOTATIONS | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/ANNOTATIONS b/ANNOTATIONS ---- a/ANNOTATIONS -+++ b/ANNOTATIONS -@@ -12,3 +12,4 @@ security changes - dma-buf changes - driver framework and misc driver changes - tty changes -+USB changes diff --git a/android-mainline/_____ANNOTATION-block-changes_____.patch b/android-mainline/_____ANNOTATION-block-changes_____.patch index 2ca19aa2..ec7470e0 100644 --- a/android-mainline/_____ANNOTATION-block-changes_____.patch +++ b/android-mainline/_____ANNOTATION-block-changes_____.patch @@ -13,7 +13,7 @@ Change-Id: I45c6df281e977b9024a9281933a30f1797104acf diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -16,3 +16,4 @@ USB changes +@@ -15,3 +15,4 @@ tty changes graphics changes sound changes UFS driver changes diff --git a/android-mainline/_____ANNOTATION-device-mapper-changes_____.patch b/android-mainline/_____ANNOTATION-device-mapper-changes_____.patch index 3deb8e6e..eb1a900a 100644 --- a/android-mainline/_____ANNOTATION-device-mapper-changes_____.patch +++ b/android-mainline/_____ANNOTATION-device-mapper-changes_____.patch @@ -13,7 +13,7 @@ Change-Id: Id05f5bf633ffbf96ae501fc1e9e39fb4dc9254cc diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -17,3 +17,4 @@ graphics changes +@@ -16,3 +16,4 @@ graphics changes sound changes UFS driver changes block changes diff --git a/android-mainline/_____ANNOTATION-filesystem-changes_____.patch b/android-mainline/_____ANNOTATION-filesystem-changes_____.patch index 40e60bc8..3989de79 100644 --- a/android-mainline/_____ANNOTATION-filesystem-changes_____.patch +++ b/android-mainline/_____ANNOTATION-filesystem-changes_____.patch @@ -13,7 +13,7 @@ Change-Id: If92180a090a8dac2e15ac12dc5e9f4ef466e01da diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -18,3 +18,4 @@ sound changes +@@ -17,3 +17,4 @@ sound changes UFS driver changes block changes device-mapper changes diff --git a/android-mainline/_____ANNOTATION-graphics-changes_____.patch b/android-mainline/_____ANNOTATION-graphics-changes_____.patch index f9951c88..29b91f97 100644 --- a/android-mainline/_____ANNOTATION-graphics-changes_____.patch +++ b/android-mainline/_____ANNOTATION-graphics-changes_____.patch @@ -13,8 +13,8 @@ Change-Id: I48fefd7a2268f5db497468dae6b5e40ad43cf4f8 diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -13,3 +13,4 @@ dma-buf changes +@@ -12,3 +12,4 @@ security changes + dma-buf changes driver framework and misc driver changes tty changes - USB changes +graphics changes diff --git a/android-mainline/_____ANNOTATION-hardware-wrapped-key-support_____.patch b/android-mainline/_____ANNOTATION-hardware-wrapped-key-support_____.patch index b9d51d00..bd4307d7 100644 --- a/android-mainline/_____ANNOTATION-hardware-wrapped-key-support_____.patch +++ b/android-mainline/_____ANNOTATION-hardware-wrapped-key-support_____.patch @@ -13,7 +13,7 @@ Change-Id: I51b2d343fdf0352248c6dc10274210ab5eb48469 diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -21,3 +21,4 @@ device-mapper changes +@@ -20,3 +20,4 @@ device-mapper changes filesystem changes Incremental filesystem networking changes diff --git a/android-mainline/_____ANNOTATION-networking-changes_____.patch b/android-mainline/_____ANNOTATION-networking-changes_____.patch index 9eec63fc..eece369c 100644 --- a/android-mainline/_____ANNOTATION-networking-changes_____.patch +++ b/android-mainline/_____ANNOTATION-networking-changes_____.patch @@ -13,7 +13,7 @@ Change-Id: Ia2dbb0cebc79534362c205acb21f29bc47132c6f diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -20,3 +20,4 @@ block changes +@@ -19,3 +19,4 @@ block changes device-mapper changes filesystem changes Incremental filesystem diff --git a/android-mainline/_____ANNOTATION-remove-ANNOTATIONS-file_____.patch b/android-mainline/_____ANNOTATION-remove-ANNOTATIONS-file_____.patch index 599de97a..3a6eda71 100644 --- a/android-mainline/_____ANNOTATION-remove-ANNOTATIONS-file_____.patch +++ b/android-mainline/_____ANNOTATION-remove-ANNOTATIONS-file_____.patch @@ -10,15 +10,15 @@ Signed-off-by: Eric Biggers Signed-off-by: Lee Jones Change-Id: Ifdec5a1ff60dd7280e1a997a750b1b82d5981c19 --- - ANNOTATIONS | 27 --------------------------- - 1 file changed, 27 deletions(-) + ANNOTATIONS | 26 -------------------------- + 1 file changed, 26 deletions(-) delete mode 100644 ANNOTATIONS diff --git a/ANNOTATIONS b/ANNOTATIONS deleted file mode 100644 --- a/ANNOTATIONS +++ /dev/null -@@ -1,27 +0,0 @@ +@@ -1,26 +0,0 @@ -pending upstream -binder changes -kbuild changes @@ -33,7 +33,6 @@ deleted file mode 100644 -dma-buf changes -driver framework and misc driver changes -tty changes --USB changes -graphics changes -sound changes -UFS driver changes diff --git a/android-mainline/_____ANNOTATION-sound-changes_____.patch b/android-mainline/_____ANNOTATION-sound-changes_____.patch index e516b5ff..fac1a6fe 100644 --- a/android-mainline/_____ANNOTATION-sound-changes_____.patch +++ b/android-mainline/_____ANNOTATION-sound-changes_____.patch @@ -13,8 +13,8 @@ Change-Id: I2839c2cff2f4bc618219c98009624102b5a1e2f1 diff --git a/ANNOTATIONS b/ANNOTATIONS --- a/ANNOTATIONS +++ b/ANNOTATIONS -@@ -14,3 +14,4 @@ driver framework and misc driver changes +@@ -13,3 +13,4 @@ dma-buf changes + driver framework and misc driver changes tty changes - USB changes graphics changes +sound changes diff --git a/android-mainline/series b/android-mainline/series index 6060f64a..65c4cb3a 100644 --- a/android-mainline/series +++ b/android-mainline/series @@ -2,8 +2,8 @@ # android-mainline patches # # Applies onto upstream e9806ff8a0f9e Linux v6.6-10372-ge9806ff8a0f9e -# Matches android-mainline 3851c83bf23ba ("ANDROID: timers: Use original names for outputs of some timer binaries") -# Status: Tested +# Matches android-mainline d23db69132acd ("ANDROID: revert out-of-tree Android USB gadget changes") +# Status: Untested # Revert-sched-core-Prevent-race-condition-between-cpuset-and-__sched_setscheduler.patch Revert-drm-virtio-fix-DRM_FORMAT_-handling.patch @@ -15,7 +15,7 @@ ANDROID-Revert-io_uring-remove-the-mode-variable-in-io_file_get_flags.patch ANDROID-Revert-io_uring-remove-__io_file_supports_nowait.patch ANDROID-Revert-io_uring-rely-solely-on-FMODE_NOWAIT.patch ANDROID-Revert-cpuidle-dt-Push-RCU-idle-into-driver.patch -ANDROID-Revert-usb-typec-tcpm-not-sink-vbus-if-operational-current-is-0mA.patch +TODO-LEE-ANDROID-Revert-usb-typec-tcpm-not-sink-vbus-if-operational-current-is-0mA.patch Revert-sched-debug-Remove-the-proc-sys-kernel-sched_child_runs_first-sysctl.patch _____ANNOTATION-pending-upstream_____.patch FROMLIST-fs-Generic-function-to-convert-iocb-to-rw-flags.patch @@ -108,16 +108,10 @@ ANDROID-gpiolib-of-add-a-quirk-for-legacy-names-in-max77759_charger.patch _____ANNOTATION-tty-changes_____.patch ANDROID-tty-hvc_dcc-Add-parameter-to-enable-DCC.patch ANDROID-Add-more-hvc-devices-for-virtio-console.patch -_____ANNOTATION-USB-changes_____.patch -NOUPSTREAM-ANDROID-usb-gadget-configfs-Add-Uevent-to-notify-userspace.patch -NOUPSTREAM-ANDROID-usb-gadget-f_accessory-Add-Android-Accessory-function.patch -NOUPSTREAM-ANDROID-usb-gadget-f_midi-create-F_midi-device.patch -NOUPSTREAM-ANDROID-usb-gadget-f_audio_source-New-gadget-driver-for-audio-output.patch _____ANNOTATION-graphics-changes_____.patch ANDROID-Allow-DRM_IOCTL_MODE_-_DUMB-for-render-clients.patch NOUPSTREAM-ANDROID-include-drm-increase-DRM-max-property-count-to-64.patch _____ANNOTATION-sound-changes_____.patch -ANDROID-SoC-core-Introduce-macro-SOC_SINGLE_MULTI_EXT.patch _____ANNOTATION-UFS-driver-changes_____.patch ANDROID-scsi-ufs-allow-overriding-the-blk_crypto_profile.patch ANDROID-scsi-ufs-add-UFSHCD_ANDROID_QUIRK_BROKEN_CRYPTO_ENABLE.patch -- cgit v1.2.3 From 6f77e0e7b0406a8972cacdc9f1d3fd681fe678a9 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 29 Jan 2024 16:55:58 +0000 Subject: aosp/android-mainline: update series (rebase onto v6.6-11104-gedd8e84ae9514) up to cdadc37d501d0 ("Merge edd8e84ae951 ("Merge tag 'sound-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound") into android-mainline") Signed-off-by: Lee Jones Change-Id: I5479c592091c2a046569e089a6123592c596ff40 --- android-mainline/ANDROID-Initial-commit-of-Incremental-FS.patch | 2 +- android-mainline/series | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android-mainline/ANDROID-Initial-commit-of-Incremental-FS.patch b/android-mainline/ANDROID-Initial-commit-of-Incremental-FS.patch index fd999eca..de44057e 100644 --- a/android-mainline/ANDROID-Initial-commit-of-Incremental-FS.patch +++ b/android-mainline/ANDROID-Initial-commit-of-Incremental-FS.patch @@ -230,7 +230,7 @@ new file mode 100644 diff --git a/MAINTAINERS b/MAINTAINERS --- a/MAINTAINERS +++ b/MAINTAINERS -@@ -10346,6 +10346,13 @@ F: Documentation/hwmon/ina2xx.rst +@@ -10347,6 +10347,13 @@ F: Documentation/hwmon/ina2xx.rst F: drivers/hwmon/ina2xx.c F: include/linux/platform_data/ina2xx.h diff --git a/android-mainline/series b/android-mainline/series index 65c4cb3a..01c9a0ef 100644 --- a/android-mainline/series +++ b/android-mainline/series @@ -1,9 +1,9 @@ # # android-mainline patches # -# Applies onto upstream e9806ff8a0f9e Linux v6.6-10372-ge9806ff8a0f9e -# Matches android-mainline d23db69132acd ("ANDROID: revert out-of-tree Android USB gadget changes") -# Status: Untested +# Applies onto upstream edd8e84ae9514 Linux v6.6-11104-gedd8e84ae9514 +# Matches android-mainline cdadc37d501d0 ("Merge edd8e84ae951 ("Merge tag 'sound-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound") into android-mainline") +# Status: Tested # Revert-sched-core-Prevent-race-condition-between-cpuset-and-__sched_setscheduler.patch Revert-drm-virtio-fix-DRM_FORMAT_-handling.patch -- cgit v1.2.3 From 2c21bc23c8b4527b053e4fbcfb20f49d30b8661a Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 29 Jan 2024 17:03:10 +0000 Subject: aosp/android-mainline: update series up to 3ee387be6b610 ("Revert "ALSA: hda: cirrus_scodec: Add KUnit test"") Signed-off-by: Lee Jones Change-Id: Ia38914a447f49c570d35798977f159eba78c4db5 --- ...ert-ALSA-hda-cirrus_scodec-Add-KUnit-test.patch | 459 +++++++++++++++++++++ ...99-Fix-Wuninitialized-in-aw_dev_set_vcalb.patch | 45 ++ ...warning-limit-with-KASAN-or-KCSAN-in-dml2.patch | 65 +++ android-mainline/series | 5 +- 4 files changed, 573 insertions(+), 1 deletion(-) create mode 100644 android-mainline/Revert-ALSA-hda-cirrus_scodec-Add-KUnit-test.patch create mode 100644 android-mainline/UPSTREAM-ASoC-codecs-aw88399-Fix-Wuninitialized-in-aw_dev_set_vcalb.patch create mode 100644 android-mainline/UPSTREAM-drm-amd-display-Increase-frame-warning-limit-with-KASAN-or-KCSAN-in-dml2.patch diff --git a/android-mainline/Revert-ALSA-hda-cirrus_scodec-Add-KUnit-test.patch b/android-mainline/Revert-ALSA-hda-cirrus_scodec-Add-KUnit-test.patch new file mode 100644 index 00000000..04fdd15c --- /dev/null +++ b/android-mainline/Revert-ALSA-hda-cirrus_scodec-Add-KUnit-test.patch @@ -0,0 +1,459 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Greg Kroah-Hartman +Date: Thu, 14 Dec 2023 11:29:55 +0000 +Subject: Revert "ALSA: hda: cirrus_scodec: Add KUnit test" + +This reverts commit 2144833e7b41459fa2d52bb0676f0ab4920cf32c. + +It breaks the Android build under clang, and there does not seem to be +any upstream reports about this. As it's only showing up in +'allmodconfig' builds, it's not relevant for Android systems at this +point in time. + +Change-Id: I49b26b30d2ae467a9f950030bf7c04fafa18dde0 +Signed-off-by: Greg Kroah-Hartman +--- + sound/pci/hda/Kconfig | 13 - + sound/pci/hda/Makefile | 2 - + sound/pci/hda/cirrus_scodec_test.c | 370 ----------------------------- + sound/pci/hda/cs35l56_hda.c | 10 - + 4 files changed, 395 deletions(-) + delete mode 100644 sound/pci/hda/cirrus_scodec_test.c + +diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig +--- a/sound/pci/hda/Kconfig ++++ b/sound/pci/hda/Kconfig +@@ -94,19 +94,6 @@ config SND_HDA_PATCH_LOADER + config SND_HDA_CIRRUS_SCODEC + tristate + +-config SND_HDA_CIRRUS_SCODEC_KUNIT_TEST +- tristate "KUnit test for Cirrus side-codec library" if !KUNIT_ALL_TESTS +- select SND_HDA_CIRRUS_SCODEC +- select GPIOLIB +- depends on KUNIT +- default KUNIT_ALL_TESTS +- help +- This builds KUnit tests for the cirrus side-codec library. +- For more information on KUnit and unit tests in general, +- please refer to the KUnit documentation in +- Documentation/dev-tools/kunit/. +- If in doubt, say "N". +- + config SND_HDA_SCODEC_CS35L41 + tristate + select SND_HDA_GENERIC +diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile +--- a/sound/pci/hda/Makefile ++++ b/sound/pci/hda/Makefile +@@ -29,7 +29,6 @@ snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o + + # side codecs + snd-hda-cirrus-scodec-objs := cirrus_scodec.o +-snd-hda-cirrus-scodec-test-objs := cirrus_scodec_test.o + snd-hda-scodec-cs35l41-objs := cs35l41_hda.o cs35l41_hda_property.o + snd-hda-scodec-cs35l41-i2c-objs := cs35l41_hda_i2c.o + snd-hda-scodec-cs35l41-spi-objs := cs35l41_hda_spi.o +@@ -59,7 +58,6 @@ obj-$(CONFIG_SND_HDA_CODEC_HDMI) += snd-hda-codec-hdmi.o + + # side codecs + obj-$(CONFIG_SND_HDA_CIRRUS_SCODEC) += snd-hda-cirrus-scodec.o +-obj-$(CONFIG_SND_HDA_CIRRUS_SCODEC_KUNIT_TEST) += snd-hda-cirrus-scodec-test.o + obj-$(CONFIG_SND_HDA_SCODEC_CS35L41) += snd-hda-scodec-cs35l41.o + obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_I2C) += snd-hda-scodec-cs35l41-i2c.o + obj-$(CONFIG_SND_HDA_SCODEC_CS35L41_SPI) += snd-hda-scodec-cs35l41-spi.o +diff --git a/sound/pci/hda/cirrus_scodec_test.c b/sound/pci/hda/cirrus_scodec_test.c +deleted file mode 100644 +--- a/sound/pci/hda/cirrus_scodec_test.c ++++ /dev/null +@@ -1,370 +0,0 @@ +-// SPDX-License-Identifier: GPL-2.0-only +-// +-// KUnit test for the Cirrus side-codec library. +-// +-// Copyright (C) 2023 Cirrus Logic, Inc. and +-// Cirrus Logic International Semiconductor Ltd. +- +-#include +-#include +-#include +-#include +- +-#include "cirrus_scodec.h" +- +-struct cirrus_scodec_test_gpio { +- unsigned int pin_state; +- struct gpio_chip chip; +-}; +- +-struct cirrus_scodec_test_priv { +- struct platform_device amp_pdev; +- struct platform_device *gpio_pdev; +- struct cirrus_scodec_test_gpio *gpio_priv; +-}; +- +-static int cirrus_scodec_test_gpio_get_direction(struct gpio_chip *chip, +- unsigned int offset) +-{ +- return GPIO_LINE_DIRECTION_IN; +-} +- +-static int cirrus_scodec_test_gpio_direction_in(struct gpio_chip *chip, +- unsigned int offset) +-{ +- return 0; +-} +- +-static int cirrus_scodec_test_gpio_get(struct gpio_chip *chip, unsigned int offset) +-{ +- struct cirrus_scodec_test_gpio *gpio_priv = gpiochip_get_data(chip); +- +- return !!(gpio_priv->pin_state & BIT(offset)); +-} +- +-static int cirrus_scodec_test_gpio_direction_out(struct gpio_chip *chip, +- unsigned int offset, int value) +-{ +- return -EOPNOTSUPP; +-} +- +-static void cirrus_scodec_test_gpio_set(struct gpio_chip *chip, unsigned int offset, +- int value) +-{ +-} +- +-static int cirrus_scodec_test_gpio_set_config(struct gpio_chip *gc, +- unsigned int offset, +- unsigned long config) +-{ +- switch (pinconf_to_config_param(config)) { +- case PIN_CONFIG_OUTPUT: +- case PIN_CONFIG_OUTPUT_ENABLE: +- return -EOPNOTSUPP; +- default: +- return 0; +- } +-} +- +-static const struct gpio_chip cirrus_scodec_test_gpio_chip = { +- .label = "cirrus_scodec_test_gpio", +- .owner = THIS_MODULE, +- .request = gpiochip_generic_request, +- .free = gpiochip_generic_free, +- .get_direction = cirrus_scodec_test_gpio_get_direction, +- .direction_input = cirrus_scodec_test_gpio_direction_in, +- .get = cirrus_scodec_test_gpio_get, +- .direction_output = cirrus_scodec_test_gpio_direction_out, +- .set = cirrus_scodec_test_gpio_set, +- .set_config = cirrus_scodec_test_gpio_set_config, +- .base = -1, +- .ngpio = 32, +-}; +- +-static int cirrus_scodec_test_gpio_probe(struct platform_device *pdev) +-{ +- struct cirrus_scodec_test_gpio *gpio_priv; +- int ret; +- +- gpio_priv = devm_kzalloc(&pdev->dev, sizeof(*gpio_priv), GFP_KERNEL); +- if (!gpio_priv) +- return -ENOMEM; +- +- /* GPIO core modifies our struct gpio_chip so use a copy */ +- gpio_priv->chip = cirrus_scodec_test_gpio_chip; +- ret = devm_gpiochip_add_data(&pdev->dev, &gpio_priv->chip, gpio_priv); +- if (ret) +- return dev_err_probe(&pdev->dev, ret, "Failed to add gpiochip\n"); +- +- dev_set_drvdata(&pdev->dev, gpio_priv); +- +- return 0; +-} +- +-static struct platform_driver cirrus_scodec_test_gpio_driver = { +- .driver.name = "cirrus_scodec_test_gpio_drv", +- .probe = cirrus_scodec_test_gpio_probe, +-}; +- +-/* software_node referencing the gpio driver */ +-static const struct software_node cirrus_scodec_test_gpio_swnode = { +- .name = "cirrus_scodec_test_gpio", +-}; +- +-static int cirrus_scodec_test_create_gpio(struct kunit *test) +-{ +- struct cirrus_scodec_test_priv *priv = test->priv; +- int ret; +- +- priv->gpio_pdev = platform_device_alloc(cirrus_scodec_test_gpio_driver.driver.name, -1); +- if (!priv->gpio_pdev) +- return -ENOMEM; +- +- ret = device_add_software_node(&priv->gpio_pdev->dev, &cirrus_scodec_test_gpio_swnode); +- if (ret) { +- platform_device_put(priv->gpio_pdev); +- KUNIT_FAIL(test, "Failed to add swnode to gpio: %d\n", ret); +- return ret; +- } +- +- ret = platform_device_add(priv->gpio_pdev); +- if (ret) { +- platform_device_put(priv->gpio_pdev); +- KUNIT_FAIL(test, "Failed to add gpio platform device: %d\n", ret); +- return ret; +- } +- +- priv->gpio_priv = dev_get_drvdata(&priv->gpio_pdev->dev); +- if (!priv->gpio_priv) { +- platform_device_put(priv->gpio_pdev); +- KUNIT_FAIL(test, "Failed to get gpio private data\n"); +- return -EINVAL; +- } +- +- return 0; +-} +- +-static void cirrus_scodec_test_set_gpio_ref_arg(struct software_node_ref_args *arg, +- int gpio_num) +-{ +- struct software_node_ref_args template = +- SOFTWARE_NODE_REFERENCE(&cirrus_scodec_test_gpio_swnode, gpio_num, 0); +- +- *arg = template; +-} +- +-static int cirrus_scodec_test_set_spkid_swnode(struct kunit *test, +- struct device *dev, +- struct software_node_ref_args *args, +- int num_args) +-{ +- const struct property_entry props_template[] = { +- PROPERTY_ENTRY_REF_ARRAY_LEN("spk-id-gpios", args, num_args), +- { } +- }; +- struct property_entry *props; +- struct software_node *node; +- +- node = kunit_kzalloc(test, sizeof(*node), GFP_KERNEL); +- if (!node) +- return -ENOMEM; +- +- props = kunit_kzalloc(test, sizeof(props_template), GFP_KERNEL); +- if (!props) +- return -ENOMEM; +- +- memcpy(props, props_template, sizeof(props_template)); +- node->properties = props; +- +- return device_add_software_node(dev, node); +-} +- +-struct cirrus_scodec_test_spkid_param { +- int num_amps; +- int gpios_per_amp; +- int num_amps_sharing; +-}; +- +-static void cirrus_scodec_test_spkid_parse(struct kunit *test) +-{ +- struct cirrus_scodec_test_priv *priv = test->priv; +- const struct cirrus_scodec_test_spkid_param *param = test->param_value; +- int num_spk_id_refs = param->num_amps * param->gpios_per_amp; +- struct software_node_ref_args *refs; +- struct device *dev = &priv->amp_pdev.dev; +- unsigned int v; +- int i, ret; +- +- refs = kunit_kcalloc(test, num_spk_id_refs, sizeof(*refs), GFP_KERNEL); +- KUNIT_ASSERT_NOT_NULL(test, refs); +- +- for (i = 0, v = 0; i < num_spk_id_refs; ) { +- cirrus_scodec_test_set_gpio_ref_arg(&refs[i++], v++); +- +- /* +- * If amps are sharing GPIOs repeat the last set of +- * GPIOs until we've done that number of amps. +- * We have done all GPIOs for an amp when i is a multiple +- * of gpios_per_amp. +- * We have done all amps sharing the same GPIOs when i is +- * a multiple of (gpios_per_amp * num_amps_sharing). +- */ +- if (!(i % param->gpios_per_amp) && +- (i % (param->gpios_per_amp * param->num_amps_sharing))) +- v -= param->gpios_per_amp; +- } +- +- ret = cirrus_scodec_test_set_spkid_swnode(test, dev, refs, num_spk_id_refs); +- KUNIT_EXPECT_EQ_MSG(test, ret, 0, "Failed to add swnode\n"); +- +- for (i = 0; i < param->num_amps; ++i) { +- for (v = 0; v < (1 << param->gpios_per_amp); ++v) { +- /* Set only the GPIO bits used by this amp */ +- priv->gpio_priv->pin_state = +- v << (param->gpios_per_amp * (i / param->num_amps_sharing)); +- +- ret = cirrus_scodec_get_speaker_id(dev, i, param->num_amps, -1); +- KUNIT_EXPECT_EQ_MSG(test, ret, v, +- "get_speaker_id failed amp:%d pin_state:%#x\n", +- i, priv->gpio_priv->pin_state); +- } +- } +-} +- +-static void cirrus_scodec_test_no_spkid(struct kunit *test) +-{ +- struct cirrus_scodec_test_priv *priv = test->priv; +- struct device *dev = &priv->amp_pdev.dev; +- int ret; +- +- ret = cirrus_scodec_get_speaker_id(dev, 0, 4, -1); +- KUNIT_EXPECT_EQ(test, ret, -ENOENT); +-} +- +-static void cirrus_scodec_test_dev_release(struct device *dev) +-{ +-} +- +-static int cirrus_scodec_test_case_init(struct kunit *test) +-{ +- struct cirrus_scodec_test_priv *priv; +- int ret; +- +- priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); +- if (!priv) +- return -ENOMEM; +- +- test->priv = priv; +- +- /* Create dummy GPIO */ +- ret = cirrus_scodec_test_create_gpio(test); +- if (ret < 0) +- return ret; +- +- /* Create dummy amp driver dev */ +- priv->amp_pdev.name = "cirrus_scodec_test_amp_drv"; +- priv->amp_pdev.id = -1; +- priv->amp_pdev.dev.release = cirrus_scodec_test_dev_release; +- ret = platform_device_register(&priv->amp_pdev); +- KUNIT_ASSERT_GE_MSG(test, ret, 0, "Failed to register amp platform device\n"); +- +- return 0; +-} +- +-static void cirrus_scodec_test_case_exit(struct kunit *test) +-{ +- struct cirrus_scodec_test_priv *priv = test->priv; +- +- if (priv->amp_pdev.name) +- platform_device_unregister(&priv->amp_pdev); +- +- if (priv->gpio_pdev) { +- device_remove_software_node(&priv->gpio_pdev->dev); +- platform_device_unregister(priv->gpio_pdev); +- } +-} +- +-static int cirrus_scodec_test_suite_init(struct kunit_suite *suite) +-{ +- int ret; +- +- /* Register mock GPIO driver */ +- ret = platform_driver_register(&cirrus_scodec_test_gpio_driver); +- if (ret < 0) { +- kunit_err(suite, "Failed to register gpio platform driver, %d\n", ret); +- return ret; +- } +- +- return 0; +-} +- +-static void cirrus_scodec_test_suite_exit(struct kunit_suite *suite) +-{ +- platform_driver_unregister(&cirrus_scodec_test_gpio_driver); +-} +- +-static const struct cirrus_scodec_test_spkid_param cirrus_scodec_test_spkid_param_cases[] = { +- { .num_amps = 2, .gpios_per_amp = 1, .num_amps_sharing = 1 }, +- { .num_amps = 2, .gpios_per_amp = 2, .num_amps_sharing = 1 }, +- { .num_amps = 2, .gpios_per_amp = 3, .num_amps_sharing = 1 }, +- { .num_amps = 2, .gpios_per_amp = 4, .num_amps_sharing = 1 }, +- { .num_amps = 3, .gpios_per_amp = 1, .num_amps_sharing = 1 }, +- { .num_amps = 3, .gpios_per_amp = 2, .num_amps_sharing = 1 }, +- { .num_amps = 3, .gpios_per_amp = 3, .num_amps_sharing = 1 }, +- { .num_amps = 3, .gpios_per_amp = 4, .num_amps_sharing = 1 }, +- { .num_amps = 4, .gpios_per_amp = 1, .num_amps_sharing = 1 }, +- { .num_amps = 4, .gpios_per_amp = 2, .num_amps_sharing = 1 }, +- { .num_amps = 4, .gpios_per_amp = 3, .num_amps_sharing = 1 }, +- { .num_amps = 4, .gpios_per_amp = 4, .num_amps_sharing = 1 }, +- +- /* Same GPIO shared by all amps */ +- { .num_amps = 2, .gpios_per_amp = 1, .num_amps_sharing = 2 }, +- { .num_amps = 2, .gpios_per_amp = 2, .num_amps_sharing = 2 }, +- { .num_amps = 2, .gpios_per_amp = 3, .num_amps_sharing = 2 }, +- { .num_amps = 2, .gpios_per_amp = 4, .num_amps_sharing = 2 }, +- { .num_amps = 3, .gpios_per_amp = 1, .num_amps_sharing = 3 }, +- { .num_amps = 3, .gpios_per_amp = 2, .num_amps_sharing = 3 }, +- { .num_amps = 3, .gpios_per_amp = 3, .num_amps_sharing = 3 }, +- { .num_amps = 3, .gpios_per_amp = 4, .num_amps_sharing = 3 }, +- { .num_amps = 4, .gpios_per_amp = 1, .num_amps_sharing = 4 }, +- { .num_amps = 4, .gpios_per_amp = 2, .num_amps_sharing = 4 }, +- { .num_amps = 4, .gpios_per_amp = 3, .num_amps_sharing = 4 }, +- { .num_amps = 4, .gpios_per_amp = 4, .num_amps_sharing = 4 }, +- +- /* Two sets of shared GPIOs */ +- { .num_amps = 4, .gpios_per_amp = 1, .num_amps_sharing = 2 }, +- { .num_amps = 4, .gpios_per_amp = 2, .num_amps_sharing = 2 }, +- { .num_amps = 4, .gpios_per_amp = 3, .num_amps_sharing = 2 }, +- { .num_amps = 4, .gpios_per_amp = 4, .num_amps_sharing = 2 }, +-}; +- +-static void cirrus_scodec_test_spkid_param_desc(const struct cirrus_scodec_test_spkid_param *param, +- char *desc) +-{ +- snprintf(desc, KUNIT_PARAM_DESC_SIZE, "amps:%d gpios_per_amp:%d num_amps_sharing:%d", +- param->num_amps, param->gpios_per_amp, param->num_amps_sharing); +-} +- +-KUNIT_ARRAY_PARAM(cirrus_scodec_test_spkid, cirrus_scodec_test_spkid_param_cases, +- cirrus_scodec_test_spkid_param_desc); +- +-static struct kunit_case cirrus_scodec_test_cases[] = { +- KUNIT_CASE_PARAM(cirrus_scodec_test_spkid_parse, cirrus_scodec_test_spkid_gen_params), +- KUNIT_CASE(cirrus_scodec_test_no_spkid), +- { } /* terminator */ +-}; +- +-static struct kunit_suite cirrus_scodec_test_suite = { +- .name = "snd-hda-scodec-cs35l56-test", +- .suite_init = cirrus_scodec_test_suite_init, +- .suite_exit = cirrus_scodec_test_suite_exit, +- .init = cirrus_scodec_test_case_init, +- .exit = cirrus_scodec_test_case_exit, +- .test_cases = cirrus_scodec_test_cases, +-}; +- +-kunit_test_suite(cirrus_scodec_test_suite); +- +-MODULE_IMPORT_NS(SND_HDA_CIRRUS_SCODEC); +-MODULE_AUTHOR("Richard Fitzgerald "); +-MODULE_LICENSE("GPL"); +diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c +--- a/sound/pci/hda/cs35l56_hda.c ++++ b/sound/pci/hda/cs35l56_hda.c +@@ -1035,16 +1035,6 @@ const struct dev_pm_ops cs35l56_hda_pm_ops = { + }; + EXPORT_SYMBOL_NS_GPL(cs35l56_hda_pm_ops, SND_HDA_SCODEC_CS35L56); + +-#if IS_ENABLED(CONFIG_SND_HDA_SCODEC_CS35L56_KUNIT_TEST) +-/* Hooks to export static function to KUnit test */ +- +-int cs35l56_hda_test_hook_get_speaker_id(struct device *dev, int amp_index, int num_amps) +-{ +- return cs35l56_hda_get_speaker_id(dev, amp_index, num_amps); +-} +-EXPORT_SYMBOL_NS_GPL(cs35l56_hda_test_hook_get_speaker_id, SND_HDA_SCODEC_CS35L56); +-#endif +- + MODULE_DESCRIPTION("CS35L56 HDA Driver"); + MODULE_IMPORT_NS(SND_HDA_CIRRUS_SCODEC); + MODULE_IMPORT_NS(SND_HDA_CS_DSP_CONTROLS); diff --git a/android-mainline/UPSTREAM-ASoC-codecs-aw88399-Fix-Wuninitialized-in-aw_dev_set_vcalb.patch b/android-mainline/UPSTREAM-ASoC-codecs-aw88399-Fix-Wuninitialized-in-aw_dev_set_vcalb.patch new file mode 100644 index 00000000..45b7bf38 --- /dev/null +++ b/android-mainline/UPSTREAM-ASoC-codecs-aw88399-Fix-Wuninitialized-in-aw_dev_set_vcalb.patch @@ -0,0 +1,45 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nathan Chancellor +Date: Fri, 27 Oct 2023 09:54:25 -0700 +Subject: UPSTREAM: ASoC: codecs: aw88399: Fix -Wuninitialized in + aw_dev_set_vcalb() + +Clang warns (or errors with CONFIG_WERROR=y): + + sound/soc/codecs/aw88399.c:441:18: error: variable 'vsense_select' is uninitialized when used here [-Werror,-Wuninitialized] + 441 | vsense_select = vsense_select & (~AW88399_VDSEL_MASK); + | ^~~~~~~~~~~~~ + sound/soc/codecs/aw88399.c:431:28: note: initialize the variable 'vsense_select' to silence this warning + 431 | unsigned int vsense_select, vsense_value; + | ^ + | = 0 + 1 error generated. + +This clearly should have been using the value received from +regmap_read(). Use the correct variable to resolve the warning. + +Closes: https://github.com/ClangBuiltLinux/linux/issues/1952 +Fixes: 8ade6cc7e261 ("ASoC: codecs: Add aw88399 amplifier driver") +Change-Id: I536ba559eed5875bb155d1ed7560c572e0885e00 +Signed-off-by: Nathan Chancellor +Reviewed-by: Weidong Wang +Link: https://lore.kernel.org/r/20231027-asoc-aw88399-fix-wuninitialized-v1-1-b1044493e4cd@kernel.org +Signed-off-by: Mark Brown +(cherry picked from commit cba4590036855f4e3110d43c14385d2401080dbb) +Signed-off-by: Greg Kroah-Hartman +--- + sound/soc/codecs/aw88399.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sound/soc/codecs/aw88399.c b/sound/soc/codecs/aw88399.c +--- a/sound/soc/codecs/aw88399.c ++++ b/sound/soc/codecs/aw88399.c +@@ -438,7 +438,7 @@ static int aw_dev_set_vcalb(struct aw88399 *aw88399) + if (ret) + return ret; + +- vsense_select = vsense_select & (~AW88399_VDSEL_MASK); ++ vsense_select = vsense_value & (~AW88399_VDSEL_MASK); + + ret = aw88399_dev_get_icalk(aw88399, &icalk); + if (ret) { diff --git a/android-mainline/UPSTREAM-drm-amd-display-Increase-frame-warning-limit-with-KASAN-or-KCSAN-in-dml2.patch b/android-mainline/UPSTREAM-drm-amd-display-Increase-frame-warning-limit-with-KASAN-or-KCSAN-in-dml2.patch new file mode 100644 index 00000000..df4c83e2 --- /dev/null +++ b/android-mainline/UPSTREAM-drm-amd-display-Increase-frame-warning-limit-with-KASAN-or-KCSAN-in-dml2.patch @@ -0,0 +1,65 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nathan Chancellor +Date: Thu, 2 Nov 2023 10:40:52 -0700 +Subject: UPSTREAM: drm/amd/display: Increase frame warning limit with KASAN or + KCSAN in dml2 + +When building ARCH=x86_64 allmodconfig with clang, which will typically +have sanitizers enabled, there is a warning about a large stack frame. + + drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/display_mode_core.c:6265:13: error: stack frame size (2520) exceeds limit (2048) in 'dml_prefetch_check' [-Werror,-Wframe-larger-than] + 6265 | static void dml_prefetch_check(struct display_mode_lib_st *mode_lib) + | ^ + 1 error generated. + +Notably, GCC 13.2.0 does not do too much of a better job, as it is right +at the current limit of 2048 (and others have reported being over with +older GCC versions): + + drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/display_mode_core.c: In function 'dml_prefetch_check': + drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/display_mode_core.c:6705:1: error: the frame size of 2048 bytes is larger than 1800 bytes [-Werror=frame-larger-than=] + 6705 | } + | ^ + +In the past, these warnings have been avoided by reducing the number of +parameters to various functions so that not as many arguments need to be +passed on the stack. However, these patches take a good amount of effort +to write despite being mechanical due to code structure and complexity +and they are never carried forward to new generations of the code so +that effort has to be expended every new hardware generation, which +becomes harder to justify as time goes on. + +To avoid having a noticeable or lengthy breakage in all{mod,yes}config, +which are easy testing targets that have -Werror enabled, increase the +limit for configurations that have KASAN or KCSAN enabled by 50% so that +cases of extremely poor code generation can still be caught while not +breaking the majority of builds. CONFIG_KMSAN also causes high stack +usage but the frame limit is already set to zero when it is enabled, +which is accounted for by the check for CONFIG_FRAME_WARN=0 in the dml2 +Makefile. + +Change-Id: I130cdf5f7b97b20bd250024c241db0bfb28fbf67 +Signed-off-by: Nathan Chancellor +Signed-off-by: Alex Deucher +(cherry picked from commit 6740ec97bcdbe96ac7df147f986c030eddfebe65) +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/display/dc/dml2/Makefile | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/gpu/drm/amd/display/dc/dml2/Makefile b/drivers/gpu/drm/amd/display/dc/dml2/Makefile +--- a/drivers/gpu/drm/amd/display/dc/dml2/Makefile ++++ b/drivers/gpu/drm/amd/display/dc/dml2/Makefile +@@ -60,8 +60,12 @@ endif + endif + + ifneq ($(CONFIG_FRAME_WARN),0) ++ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y) ++frame_warn_flag := -Wframe-larger-than=3072 ++else + frame_warn_flag := -Wframe-larger-than=2048 + endif ++endif + + CFLAGS_$(AMDDALPATH)/dc/dml2/display_mode_core.o := $(dml2_ccflags) $(frame_warn_flag) + CFLAGS_$(AMDDALPATH)/dc/dml2/display_mode_util.o := $(dml2_ccflags) diff --git a/android-mainline/series b/android-mainline/series index 01c9a0ef..0f6f38c8 100644 --- a/android-mainline/series +++ b/android-mainline/series @@ -2,7 +2,7 @@ # android-mainline patches # # Applies onto upstream edd8e84ae9514 Linux v6.6-11104-gedd8e84ae9514 -# Matches android-mainline cdadc37d501d0 ("Merge edd8e84ae951 ("Merge tag 'sound-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound") into android-mainline") +# Matches android-mainline 3ee387be6b610 ("Revert "ALSA: hda: cirrus_scodec: Add KUnit test"") # Status: Tested # Revert-sched-core-Prevent-race-condition-between-cpuset-and-__sched_setscheduler.patch @@ -10,6 +10,7 @@ Revert-drm-virtio-fix-DRM_FORMAT_-handling.patch Revert-of-unittest-Disable-new-dtc-node_name_vs_property_name-and-interrupt_map-warnings.patch Revert-staging-remove-ashmem.patch Revert-usb-typec-tcpm-fix-cc-role-at-port-reset.patch +Revert-ALSA-hda-cirrus_scodec-Add-KUnit-test.patch ANDROID-Revert-perf-core-Use-static_call-to-optimize-perf_guest_info_callbacks.patch ANDROID-Revert-io_uring-remove-the-mode-variable-in-io_file_get_flags.patch ANDROID-Revert-io_uring-remove-__io_file_supports_nowait.patch @@ -38,6 +39,8 @@ FROMLIST-fs-select-mark-do_select-noinline_for_stack.patch UPSTREAM-cpuidle-dt-Push-RCU-idle-into-driver.patch FROMLIST-kheaders-dereferences-the-source-tree.patch FROMLIST-Revert-fuse-Apply-flags2-only-when-userspace-set-the-FUSE_INIT_EXT.patch +UPSTREAM-ASoC-codecs-aw88399-Fix-Wuninitialized-in-aw_dev_set_vcalb.patch +UPSTREAM-drm-amd-display-Increase-frame-warning-limit-with-KASAN-or-KCSAN-in-dml2.patch _____ANNOTATION-binder-changes_____.patch ONHOLD-ANDROID-binder-add-support-for-RT-prio-inheritance.patch ANDROID-binder-fold-common-setup-of-node_prio.patch -- cgit v1.2.3 From 59e298367116bdd3b145cd3048015055bb23eeef Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 29 Jan 2024 17:03:54 +0000 Subject: aosp/android-mainline: update series (rebase onto v6.6-11236-g90a300dc0553c) up to 634f767cf898b ("Merge 90a300dc0553 ("Merge tag 'libnvdimm-for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm") into android-mainline") Signed-off-by: Lee Jones Change-Id: I10773b5212fb08c0db02ee65c8a19549e3ec4b58 --- android-mainline/series | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android-mainline/series b/android-mainline/series index 0f6f38c8..f84d12ad 100644 --- a/android-mainline/series +++ b/android-mainline/series @@ -1,8 +1,8 @@ # # android-mainline patches # -# Applies onto upstream edd8e84ae9514 Linux v6.6-11104-gedd8e84ae9514 -# Matches android-mainline 3ee387be6b610 ("Revert "ALSA: hda: cirrus_scodec: Add KUnit test"") +# Applies onto upstream 90a300dc0553c Linux v6.6-11236-g90a300dc0553c +# Matches android-mainline 634f767cf898b ("Merge 90a300dc0553 ("Merge tag 'libnvdimm-for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm") into android-mainline") # Status: Tested # Revert-sched-core-Prevent-race-condition-between-cpuset-and-__sched_setscheduler.patch -- cgit v1.2.3 From 66bd8acf9fac468882e2d08b72d4515520c79af6 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 29 Jan 2024 17:04:42 +0000 Subject: aosp/android-mainline: update series (rebase onto v6.6-11379-g6ed92e559a2ea) up to cf6b5b03d0d09 ("Merge 6ed92e559a2e ("Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi") into android-mainline") Signed-off-by: Lee Jones Change-Id: I2d3a7b96a85d18caae698030c9ec7ddb2bfd6430 --- ...UFSHCD_ANDROID_QUIRK_BROKEN_CRYPTO_ENABLE.patch | 2 +- ...ufs-add-UFSHCD_ANDROID_QUIRK_KEYS_IN_PRDT.patch | 4 ++-- ...s-allow-overriding-the-blk_crypto_profile.patch | 2 +- ...-error-relating-to-ufshcd_read_desc_param.patch | 2 +- .../NOUPSTREAM-ANDROID-scsi-SCSI-UFS-Exports.patch | 20 +++++++++--------- ...AM-ANDROID-scsi-SCSI-related-vendor-hooks.patch | 24 +++++++++++----------- android-mainline/series | 4 ++-- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/android-mainline/ANDROID-scsi-ufs-add-UFSHCD_ANDROID_QUIRK_BROKEN_CRYPTO_ENABLE.patch b/android-mainline/ANDROID-scsi-ufs-add-UFSHCD_ANDROID_QUIRK_BROKEN_CRYPTO_ENABLE.patch index b5e12f50..98115ec4 100644 --- a/android-mainline/ANDROID-scsi-ufs-add-UFSHCD_ANDROID_QUIRK_BROKEN_CRYPTO_ENABLE.patch +++ b/android-mainline/ANDROID-scsi-ufs-add-UFSHCD_ANDROID_QUIRK_BROKEN_CRYPTO_ENABLE.patch @@ -40,7 +40,7 @@ diff --git a/drivers/ufs/core/ufshcd-crypto.c b/drivers/ufs/core/ufshcd-crypto.c diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h -@@ -657,6 +657,15 @@ enum ufshcd_android_quirks { +@@ -656,6 +656,15 @@ enum ufshcd_android_quirks { * ufs_hba_variant_ops::init() must do it instead. */ UFSHCD_ANDROID_QUIRK_CUSTOM_CRYPTO_PROFILE = 1 << 0, diff --git a/android-mainline/ANDROID-scsi-ufs-add-UFSHCD_ANDROID_QUIRK_KEYS_IN_PRDT.patch b/android-mainline/ANDROID-scsi-ufs-add-UFSHCD_ANDROID_QUIRK_KEYS_IN_PRDT.patch index 7a76a161..2c729a25 100644 --- a/android-mainline/ANDROID-scsi-ufs-add-UFSHCD_ANDROID_QUIRK_KEYS_IN_PRDT.patch +++ b/android-mainline/ANDROID-scsi-ufs-add-UFSHCD_ANDROID_QUIRK_KEYS_IN_PRDT.patch @@ -59,7 +59,7 @@ diff --git a/drivers/ufs/core/ufshcd-crypto.h b/drivers/ufs/core/ufshcd-crypto.h diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c -@@ -5369,6 +5369,7 @@ void ufshcd_release_scsi_cmd(struct ufs_hba *hba, +@@ -5467,6 +5467,7 @@ void ufshcd_release_scsi_cmd(struct ufs_hba *hba, struct scsi_cmnd *cmd = lrbp->cmd; scsi_dma_unmap(cmd); @@ -70,7 +70,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h -@@ -666,6 +666,15 @@ enum ufshcd_android_quirks { +@@ -665,6 +665,15 @@ enum ufshcd_android_quirks { * breaks the HCE sequence if used. */ UFSHCD_ANDROID_QUIRK_BROKEN_CRYPTO_ENABLE = 1 << 1, diff --git a/android-mainline/ANDROID-scsi-ufs-allow-overriding-the-blk_crypto_profile.patch b/android-mainline/ANDROID-scsi-ufs-allow-overriding-the-blk_crypto_profile.patch index 820a70ac..31f01ebd 100644 --- a/android-mainline/ANDROID-scsi-ufs-allow-overriding-the-blk_crypto_profile.patch +++ b/android-mainline/ANDROID-scsi-ufs-allow-overriding-the-blk_crypto_profile.patch @@ -64,7 +64,7 @@ diff --git a/drivers/ufs/core/ufshcd-crypto.c b/drivers/ufs/core/ufshcd-crypto.c diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h -@@ -645,6 +645,20 @@ enum ufshcd_quirks { +@@ -644,6 +644,20 @@ enum ufshcd_quirks { UFSHCD_QUIRK_MCQ_BROKEN_RTC = 1 << 21, }; diff --git a/android-mainline/FIXME-ufs-Merge-error-relating-to-ufshcd_read_desc_param.patch b/android-mainline/FIXME-ufs-Merge-error-relating-to-ufshcd_read_desc_param.patch index 4257b168..2e7c8cde 100644 --- a/android-mainline/FIXME-ufs-Merge-error-relating-to-ufshcd_read_desc_param.patch +++ b/android-mainline/FIXME-ufs-Merge-error-relating-to-ufshcd_read_desc_param.patch @@ -12,7 +12,7 @@ Change-Id: Id499109fa415cb5a217e4832e7dc0259cee1a5c7 diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h -@@ -1390,6 +1390,12 @@ static inline int ufshcd_disable_host_tx_lcc(struct ufs_hba *hba) +@@ -1394,6 +1394,12 @@ static inline int ufshcd_disable_host_tx_lcc(struct ufs_hba *hba) return ufshcd_dme_set(hba, UIC_ARG_MIB(PA_LOCAL_TX_LCC_ENABLE), 0); } diff --git a/android-mainline/NOUPSTREAM-ANDROID-scsi-SCSI-UFS-Exports.patch b/android-mainline/NOUPSTREAM-ANDROID-scsi-SCSI-UFS-Exports.patch index 0c02b275..1a3cbb31 100644 --- a/android-mainline/NOUPSTREAM-ANDROID-scsi-SCSI-UFS-Exports.patch +++ b/android-mainline/NOUPSTREAM-ANDROID-scsi-SCSI-UFS-Exports.patch @@ -28,7 +28,7 @@ Signed-off-by: Lee Jones diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c -@@ -3205,7 +3205,7 @@ static inline void ufshcd_init_query(struct ufs_hba *hba, +@@ -3301,7 +3301,7 @@ static inline void ufshcd_init_query(struct ufs_hba *hba, (*request)->upiu_req.selector = selector; } @@ -37,7 +37,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c enum query_opcode opcode, enum flag_idn idn, u8 index, bool *flag_res) { int ret; -@@ -3227,6 +3227,7 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba, +@@ -3323,6 +3323,7 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba, __func__, opcode, idn, ret, retries); return ret; } @@ -45,7 +45,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c /** * ufshcd_query_flag() - API function for sending flag query requests -@@ -3295,6 +3296,7 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, +@@ -3391,6 +3392,7 @@ int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, ufshcd_release(hba); return err; } @@ -53,7 +53,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c /** * ufshcd_query_attr - API function for sending attribute requests -@@ -3358,6 +3360,7 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, +@@ -3454,6 +3456,7 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, ufshcd_release(hba); return err; } @@ -61,7 +61,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c /** * ufshcd_query_attr_retry() - API function for sending query -@@ -3395,6 +3398,7 @@ int ufshcd_query_attr_retry(struct ufs_hba *hba, +@@ -3491,6 +3494,7 @@ int ufshcd_query_attr_retry(struct ufs_hba *hba, __func__, idn, ret, QUERY_REQ_RETRIES); return ret; } @@ -69,7 +69,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c static int __ufshcd_query_descriptor(struct ufs_hba *hba, enum query_opcode opcode, enum desc_idn idn, u8 index, -@@ -3491,6 +3495,7 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba, +@@ -3587,6 +3591,7 @@ int ufshcd_query_descriptor_retry(struct ufs_hba *hba, return err; } @@ -77,7 +77,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c /** * ufshcd_read_desc_param - read the specified descriptor parameter -@@ -3570,6 +3575,7 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, +@@ -3666,6 +3671,7 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, kfree(desc_buf); return ret; } @@ -85,7 +85,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c /** * struct uc_string_id - unicode string -@@ -5786,7 +5792,7 @@ static inline int ufshcd_get_bkops_status(struct ufs_hba *hba, u32 *status) +@@ -5883,7 +5889,7 @@ static inline int ufshcd_get_bkops_status(struct ufs_hba *hba, u32 *status) * to know whether auto bkops is enabled or disabled after this function * returns control to it. */ @@ -94,7 +94,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c enum bkops_status status) { int err; -@@ -5811,6 +5817,7 @@ static int ufshcd_bkops_ctrl(struct ufs_hba *hba, +@@ -5908,6 +5914,7 @@ static int ufshcd_bkops_ctrl(struct ufs_hba *hba, out: return err; } @@ -105,7 +105,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h -@@ -1396,6 +1396,14 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, +@@ -1400,6 +1400,14 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, u8 param_offset, u8 *param_read_buf, u8 param_size); diff --git a/android-mainline/NOUPSTREAM-ANDROID-scsi-SCSI-related-vendor-hooks.patch b/android-mainline/NOUPSTREAM-ANDROID-scsi-SCSI-related-vendor-hooks.patch index 19a2e5a3..80f2cbb1 100644 --- a/android-mainline/NOUPSTREAM-ANDROID-scsi-SCSI-related-vendor-hooks.patch +++ b/android-mainline/NOUPSTREAM-ANDROID-scsi-SCSI-related-vendor-hooks.patch @@ -49,7 +49,7 @@ diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c -@@ -40,6 +40,9 @@ +@@ -41,6 +41,9 @@ #define CREATE_TRACE_POINTS #include @@ -59,7 +59,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c #define UFSHCD_ENABLE_INTRS (UTP_TRANSFER_REQ_COMPL |\ UTP_TASK_REQ_COMPL |\ UFSHCD_ERROR_MASK) -@@ -363,6 +366,8 @@ static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, +@@ -364,6 +367,8 @@ static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, { struct utp_task_req_desc *descp = &hba->utmrdl_base_addr[tag]; @@ -68,7 +68,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c if (!trace_ufshcd_upiu_enabled()) return; -@@ -384,6 +389,8 @@ static void ufshcd_add_uic_command_trace(struct ufs_hba *hba, +@@ -385,6 +390,8 @@ static void ufshcd_add_uic_command_trace(struct ufs_hba *hba, { u32 cmd; @@ -77,15 +77,15 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c if (!trace_ufshcd_uic_command_enabled()) return; -@@ -2164,6 +2171,7 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, +@@ -2265,6 +2272,7 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, lrbp->issue_time_stamp_local_clock = local_clock(); lrbp->compl_time_stamp = ktime_set(0, 0); lrbp->compl_time_stamp_local_clock = 0; + trace_android_vh_ufs_send_command(hba, lrbp); ufshcd_add_command_trace(hba, task_tag, UFS_CMD_SEND); - ufshcd_clk_scaling_start_busy(hba); - if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) -@@ -2498,13 +2506,16 @@ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) + if (lrbp->cmd) + ufshcd_clk_scaling_start_busy(hba); +@@ -2600,13 +2608,16 @@ static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { struct scsi_cmnd *cmd = lrbp->cmd; int sg_segments = scsi_dma_map(cmd); @@ -103,7 +103,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c } /** -@@ -2880,6 +2891,14 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) +@@ -2976,6 +2987,14 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) ufshcd_prepare_lrbp_crypto(scsi_cmd_to_rq(cmd), lrbp); @@ -118,7 +118,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c lrbp->req_abort_skip = false; ufshcd_comp_scsi_upiu(hba, lrbp); -@@ -5391,6 +5410,7 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag, +@@ -5489,6 +5508,7 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag, lrbp->compl_time_stamp = ktime_get(); cmd = lrbp->cmd; if (cmd) { @@ -126,7 +126,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) ufshcd_update_monitor(hba, lrbp); ufshcd_add_command_trace(hba, task_tag, UFS_CMD_COMP); -@@ -5401,6 +5421,7 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag, +@@ -5499,6 +5519,7 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag, } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE || lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) { if (hba->dev_cmd.complete) { @@ -134,7 +134,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c if (cqe) { ocs = le32_to_cpu(cqe->status) & MASK_OCS; lrbp->utr_descriptor_ptr->header.ocs = ocs; -@@ -6698,6 +6719,8 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba, u32 intr_status) +@@ -6795,6 +6816,8 @@ static irqreturn_t ufshcd_check_errors(struct ufs_hba *hba, u32 intr_status) queue_eh_work = true; } @@ -143,7 +143,7 @@ diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c if (queue_eh_work) { /* * update the transfer error masks to sticky bits, let's do this -@@ -10440,7 +10463,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) +@@ -10558,7 +10581,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) ufshcd_set_ufs_dev_active(hba); async_schedule(ufshcd_async_scan, hba); diff --git a/android-mainline/series b/android-mainline/series index f84d12ad..2194131d 100644 --- a/android-mainline/series +++ b/android-mainline/series @@ -1,8 +1,8 @@ # # android-mainline patches # -# Applies onto upstream 90a300dc0553c Linux v6.6-11236-g90a300dc0553c -# Matches android-mainline 634f767cf898b ("Merge 90a300dc0553 ("Merge tag 'libnvdimm-for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm") into android-mainline") +# Applies onto upstream 6ed92e559a2ea Linux v6.6-11379-g6ed92e559a2ea +# Matches android-mainline cf6b5b03d0d09 ("Merge 6ed92e559a2e ("Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi") into android-mainline") # Status: Tested # Revert-sched-core-Prevent-race-condition-between-cpuset-and-__sched_setscheduler.patch -- cgit v1.2.3 From 2fcefbee824a331ac661890f8f2cc699846dcb27 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 29 Jan 2024 17:05:46 +0000 Subject: aosp/android-mainline: update series (rebase onto v6.6-11432-g43468456c95b9) up to 7cc5934963eb8 ("Merge 43468456c95b ("Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma") into android-mainline") Signed-off-by: Lee Jones Change-Id: I91fb57fc4d3338d2699ceec9fb662e746a935b08 --- android-mainline/series | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android-mainline/series b/android-mainline/series index 2194131d..aeaefb7d 100644 --- a/android-mainline/series +++ b/android-mainline/series @@ -1,8 +1,8 @@ # # android-mainline patches # -# Applies onto upstream 6ed92e559a2ea Linux v6.6-11379-g6ed92e559a2ea -# Matches android-mainline cf6b5b03d0d09 ("Merge 6ed92e559a2e ("Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi") into android-mainline") +# Applies onto upstream 43468456c95b9 Linux v6.6-11432-g43468456c95b9 +# Matches android-mainline 7cc5934963eb8 ("Merge 43468456c95b ("Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma") into android-mainline") # Status: Tested # Revert-sched-core-Prevent-race-condition-between-cpuset-and-__sched_setscheduler.patch -- cgit v1.2.3 From 03d030d4f3dba049ef77f8093547dd239a55bf21 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 29 Jan 2024 17:06:55 +0000 Subject: aosp/android-mainline: update series (rebase onto v6.6-11644-g6803bd7956ca8) up to 35749bff77e44 ("Merge 6803bd7956ca ("Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm") into android-mainline") Signed-off-by: Lee Jones Change-Id: Ia0de4e3c0fc8755df3dda813320ae4273e47a367 --- android-mainline/ANDROID-GKI-Disable-KUnit-built-in-testing.patch | 2 +- .../ANDROID-tty-hvc_dcc-Add-parameter-to-enable-DCC.patch | 2 +- android-mainline/series | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android-mainline/ANDROID-GKI-Disable-KUnit-built-in-testing.patch b/android-mainline/ANDROID-GKI-Disable-KUnit-built-in-testing.patch index b4fcf3b9..1e241090 100644 --- a/android-mainline/ANDROID-GKI-Disable-KUnit-built-in-testing.patch +++ b/android-mainline/ANDROID-GKI-Disable-KUnit-built-in-testing.patch @@ -25,7 +25,7 @@ Signed-off-by: Lee Jones diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt -@@ -2534,7 +2534,7 @@ +@@ -2537,7 +2537,7 @@ CONFIG_KUNIT to be set to be fully enabled. The default value can be overridden via KUNIT_DEFAULT_ENABLED. diff --git a/android-mainline/ANDROID-tty-hvc_dcc-Add-parameter-to-enable-DCC.patch b/android-mainline/ANDROID-tty-hvc_dcc-Add-parameter-to-enable-DCC.patch index 7700a01a..a4d6d959 100644 --- a/android-mainline/ANDROID-tty-hvc_dcc-Add-parameter-to-enable-DCC.patch +++ b/android-mainline/ANDROID-tty-hvc_dcc-Add-parameter-to-enable-DCC.patch @@ -21,7 +21,7 @@ Signed-off-by: Lee Jones diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt -@@ -1834,6 +1834,10 @@ +@@ -1837,6 +1837,10 @@ If specified, z/VM IUCV HVC accepts connections from listed z/VM user IDs only. diff --git a/android-mainline/series b/android-mainline/series index aeaefb7d..a83ef1f0 100644 --- a/android-mainline/series +++ b/android-mainline/series @@ -1,8 +1,8 @@ # # android-mainline patches # -# Applies onto upstream 43468456c95b9 Linux v6.6-11432-g43468456c95b9 -# Matches android-mainline 7cc5934963eb8 ("Merge 43468456c95b ("Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma") into android-mainline") +# Applies onto upstream 6803bd7956ca8 Linux v6.6-11644-g6803bd7956ca8 +# Matches android-mainline 35749bff77e44 ("Merge 6803bd7956ca ("Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm") into android-mainline") # Status: Tested # Revert-sched-core-Prevent-race-condition-between-cpuset-and-__sched_setscheduler.patch -- cgit v1.2.3 From 8de056dbd738a6a0499893d039a7568bb7b32e03 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 29 Jan 2024 17:08:01 +0000 Subject: aosp/android-mainline: update series (rebase onto v6.6-11928-gbc3012f4e3a97) up to f418eba96833c ("Merge bc3012f4e3a9 ("Merge tag 'v6.7-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6") into android-mainline") Signed-off-by: Lee Jones Change-Id: Ida184816b542dc2ff500df66c20b006dccdb54c1 --- .../NOUPSTREAM-ANDROID-init-GKI-add-GKI_HACKS_TO_FIX.patch | 2 +- ...OID-net-xfrm-make-PF_KEY-SHA256-use-RFC-compliant-truncation.patch | 2 +- android-mainline/series | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android-mainline/NOUPSTREAM-ANDROID-init-GKI-add-GKI_HACKS_TO_FIX.patch b/android-mainline/NOUPSTREAM-ANDROID-init-GKI-add-GKI_HACKS_TO_FIX.patch index cf9bd8a6..637cbc7f 100644 --- a/android-mainline/NOUPSTREAM-ANDROID-init-GKI-add-GKI_HACKS_TO_FIX.patch +++ b/android-mainline/NOUPSTREAM-ANDROID-init-GKI-add-GKI_HACKS_TO_FIX.patch @@ -338,7 +338,7 @@ new file mode 100644 diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c -@@ -237,7 +237,7 @@ static struct xfrm_algo_desc aalg_list[] = { +@@ -238,7 +238,7 @@ static struct xfrm_algo_desc aalg_list[] = { .uinfo = { .auth = { diff --git a/android-mainline/NOUPSTREAM-ANDROID-net-xfrm-make-PF_KEY-SHA256-use-RFC-compliant-truncation.patch b/android-mainline/NOUPSTREAM-ANDROID-net-xfrm-make-PF_KEY-SHA256-use-RFC-compliant-truncation.patch index bcdf641f..f768b08f 100644 --- a/android-mainline/NOUPSTREAM-ANDROID-net-xfrm-make-PF_KEY-SHA256-use-RFC-compliant-truncation.patch +++ b/android-mainline/NOUPSTREAM-ANDROID-net-xfrm-make-PF_KEY-SHA256-use-RFC-compliant-truncation.patch @@ -35,7 +35,7 @@ Signed-off-by: Lee Jones diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c --- a/net/xfrm/xfrm_algo.c +++ b/net/xfrm/xfrm_algo.c -@@ -237,7 +237,7 @@ static struct xfrm_algo_desc aalg_list[] = { +@@ -238,7 +238,7 @@ static struct xfrm_algo_desc aalg_list[] = { .uinfo = { .auth = { diff --git a/android-mainline/series b/android-mainline/series index a83ef1f0..80f51450 100644 --- a/android-mainline/series +++ b/android-mainline/series @@ -1,8 +1,8 @@ # # android-mainline patches # -# Applies onto upstream 6803bd7956ca8 Linux v6.6-11644-g6803bd7956ca8 -# Matches android-mainline 35749bff77e44 ("Merge 6803bd7956ca ("Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm") into android-mainline") +# Applies onto upstream bc3012f4e3a97 Linux v6.6-11928-gbc3012f4e3a97 +# Matches android-mainline f418eba96833c ("Merge bc3012f4e3a9 ("Merge tag 'v6.7-p1' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6") into android-mainline") # Status: Tested # Revert-sched-core-Prevent-race-condition-between-cpuset-and-__sched_setscheduler.patch -- cgit v1.2.3 From 95567db55cd51e093d208b9f9945c2d04e489d09 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Mon, 29 Jan 2024 17:19:01 +0000 Subject: aosp/android-mainline: update series up to c010a3f3423d6 ("ANDROID: Add dist rules for tests zip") Signed-off-by: Lee Jones Change-Id: Ib388dc31f4fa38933b13cb7da491fe2a8dc52e66 --- android-mainline/ANDROID-tools-Miscellaneous.patch | 58 +++-- ...NDROID-Kleaf-Bazel-based-GKI-kernel-build.patch | 285 ++++++++++++++++++++- ...STREAM-ANDROID-kernel-Core-Kernel-Exports.patch | 14 +- .../Revert-crypto-pkcs7-remove-sha1-support.patch | 267 +++++++++++++++++++ android-mainline/series | 3 +- 5 files changed, 587 insertions(+), 40 deletions(-) create mode 100644 android-mainline/Revert-crypto-pkcs7-remove-sha1-support.patch diff --git a/android-mainline/ANDROID-tools-Miscellaneous.patch b/android-mainline/ANDROID-tools-Miscellaneous.patch index 218ee094..a3903ced 100644 --- a/android-mainline/ANDROID-tools-Miscellaneous.patch +++ b/android-mainline/ANDROID-tools-Miscellaneous.patch @@ -9,14 +9,15 @@ Change-Id: Ic155709fbf07ec0575fa2fa954ee199e63051a97 tools/testing/android/OWNERS | 4 + tools/testing/android/bin/acloudb.sh | 43 +++++++++ tools/testing/android/bin/kselftest.sh | 88 +++++++++++++++++++ - .../selftests/android/config_arm64.xml | 84 ++++++++++++++++++ + .../selftests/android/config_arm64.xml | 78 ++++++++++++++++ .../selftests/android/config_x86_64.xml | 84 ++++++++++++++++++ .../filesystems/binderfs/binderfs_test.c | 10 +++ .../selftests/futex/functional/futex_wait.c | 6 ++ .../futex/functional/futex_wait_timeout.c | 11 ++- .../futex/functional/futex_wait_wouldblock.c | 13 ++- + tools/testing/selftests/net/psock_tpacket.c | 2 + tools/testing/selftests/rtc/rtctest.c | 2 + - 10 files changed, 338 insertions(+), 7 deletions(-) + 11 files changed, 334 insertions(+), 7 deletions(-) create mode 100644 tools/testing/android/OWNERS create mode 100755 tools/testing/android/bin/acloudb.sh create mode 100755 tools/testing/android/bin/kselftest.sh @@ -177,7 +178,7 @@ diff --git a/tools/testing/selftests/android/config_arm64.xml b/tools/testing/se new file mode 100644 --- /dev/null +++ b/tools/testing/selftests/android/config_arm64.xml -@@ -0,0 +1,84 @@ +@@ -0,0 +1,78 @@ + +