linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Archie Pusaka <apusaka@google.com>
To: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
	chromeos-bluetooth-upstreaming 
	<chromeos-bluetooth-upstreaming@chromium.org>,
	Marcel Holtmann <marcel@holtmann.org>
Cc: drinkcat@chromium.org, BlueZ <linux-bluetooth@vger.kernel.org>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Bluetooth: hci_h5: Add driver capabilities for RTL8822CS
Date: Mon, 3 May 2021 13:32:38 +0800	[thread overview]
Message-ID: <CAJQfnxHcag62zp4_0R9=KomC7FJB=xaRbmfaHsTp8JrOgkV9Pg@mail.gmail.com> (raw)
In-Reply-To: <20201009133147.1.Ie792480ac24829a48669e83c0045157eb3d46775@changeid>

Hi maintainers,

Could you take another look at this patch?

Thanks,
Archie


On Sat, 10 Oct 2020 at 04:32, Abhishek Pandit-Subedi
<abhishekpandit@chromium.org> wrote:
>
> Certain controller capabilities must be exposed by the driver because it
> can't be queried from HCI (wideband speech support, for example). Update
> the match data structure to set the supported capabilities and set the
> proper quirks on hdev after registering the device.
>
> Also update the 8822CS capabilities to show it supports wideband speech
> and has valid le states (allows central peripheral role).
>
> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> ---
>
>  drivers/bluetooth/hci_h5.c | 53 +++++++++++++++++++++++++++++++-------
>  1 file changed, 44 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
> index a10d710fc3f13e..3833a2d276665f 100644
> --- a/drivers/bluetooth/hci_h5.c
> +++ b/drivers/bluetooth/hci_h5.c
> @@ -97,6 +97,11 @@ struct h5 {
>         struct gpio_desc *device_wake_gpio;
>  };
>
> +enum h5_capabilities {
> +       H5_CAP_WIDEBAND_SPEECH = BIT(0),
> +       H5_CAP_VALID_LE_STATES = BIT(1),
> +};
> +
>  struct h5_vnd {
>         int (*setup)(struct h5 *h5);
>         void (*open)(struct h5 *h5);
> @@ -106,6 +111,11 @@ struct h5_vnd {
>         const struct acpi_gpio_mapping *acpi_gpio_map;
>  };
>
> +struct h5_device_data {
> +       uint32_t capabilities;
> +       struct h5_vnd *vnd;
> +};
> +
>  static void h5_reset_rx(struct h5 *h5);
>
>  static void h5_link_control(struct hci_uart *hu, const void *data, size_t len)
> @@ -791,7 +801,10 @@ static const struct hci_uart_proto h5p = {
>  static int h5_serdev_probe(struct serdev_device *serdev)
>  {
>         struct device *dev = &serdev->dev;
> +       struct hci_dev *hdev;
>         struct h5 *h5;
> +       const struct h5_device_data *data;
> +       int err;
>
>         h5 = devm_kzalloc(dev, sizeof(*h5), GFP_KERNEL);
>         if (!h5)
> @@ -808,23 +821,21 @@ static int h5_serdev_probe(struct serdev_device *serdev)
>                 if (!match)
>                         return -ENODEV;
>
> -               h5->vnd = (const struct h5_vnd *)match->driver_data;
> +               data = (const struct h5_device_data *)match->driver_data;
> +               h5->vnd = data->vnd;
>                 h5->id  = (char *)match->id;
>
>                 if (h5->vnd->acpi_gpio_map)
>                         devm_acpi_dev_add_driver_gpios(dev,
>                                                        h5->vnd->acpi_gpio_map);
>         } else {
> -               const void *data;
> -
>                 data = of_device_get_match_data(dev);
>                 if (!data)
>                         return -ENODEV;
>
> -               h5->vnd = (const struct h5_vnd *)data;
> +               h5->vnd = data->vnd;
>         }
>
> -
>         h5->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW);
>         if (IS_ERR(h5->enable_gpio))
>                 return PTR_ERR(h5->enable_gpio);
> @@ -834,7 +845,20 @@ static int h5_serdev_probe(struct serdev_device *serdev)
>         if (IS_ERR(h5->device_wake_gpio))
>                 return PTR_ERR(h5->device_wake_gpio);
>
> -       return hci_uart_register_device(&h5->serdev_hu, &h5p);
> +       err = hci_uart_register_device(&h5->serdev_hu, &h5p);
> +       if (err)
> +               return err;
> +
> +       hdev = h5->serdev_hu.hdev;
> +
> +       /* Set match specific quirks */
> +       if (data->capabilities & H5_CAP_WIDEBAND_SPEECH)
> +               set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks);
> +
> +       if (data->capabilities & H5_CAP_VALID_LE_STATES)
> +               set_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks);
> +
> +       return 0;
>  }
>
>  static void h5_serdev_remove(struct serdev_device *serdev)
> @@ -1000,12 +1024,21 @@ static struct h5_vnd rtl_vnd = {
>         .resume         = h5_btrtl_resume,
>         .acpi_gpio_map  = acpi_btrtl_gpios,
>  };
> +
> +static const struct h5_device_data h5_data_rtl8822cs = {
> +       .capabilities = H5_CAP_WIDEBAND_SPEECH | H5_CAP_VALID_LE_STATES,
> +       .vnd = &rtl_vnd,
> +};
> +
> +static const struct h5_device_data h5_data_rtl8723bs = {
> +       .vnd = &rtl_vnd,
> +};
>  #endif
>
>  #ifdef CONFIG_ACPI
>  static const struct acpi_device_id h5_acpi_match[] = {
>  #ifdef CONFIG_BT_HCIUART_RTL
> -       { "OBDA8723", (kernel_ulong_t)&rtl_vnd },
> +       { "OBDA8723", (kernel_ulong_t)&h5_data_rtl8723bs},
>  #endif
>         { },
>  };
> @@ -1019,9 +1052,11 @@ static const struct dev_pm_ops h5_serdev_pm_ops = {
>  static const struct of_device_id rtl_bluetooth_of_match[] = {
>  #ifdef CONFIG_BT_HCIUART_RTL
>         { .compatible = "realtek,rtl8822cs-bt",
> -         .data = (const void *)&rtl_vnd },
> +         .data = &h5_data_rtl8822cs,
> +       },
>         { .compatible = "realtek,rtl8723bs-bt",
> -         .data = (const void *)&rtl_vnd },
> +         .data = &h5_data_rtl8723bs,
> +       },
>  #endif
>         { },
>  };
> --
> 2.28.0.1011.ga647a8990f-goog
>
> --
> You received this message because you are subscribed to the Google Groups "ChromeOS Bluetooth Upstreaming" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to chromeos-bluetooth-upstreaming+unsubscribe@chromium.org.
> To post to this group, send email to chromeos-bluetooth-upstreaming@chromium.org.
> To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromeos-bluetooth-upstreaming/20201009133147.1.Ie792480ac24829a48669e83c0045157eb3d46775%40changeid.

      reply	other threads:[~2021-05-03  5:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 20:32 [PATCH] Bluetooth: hci_h5: Add driver capabilities for RTL8822CS Abhishek Pandit-Subedi
2021-05-03  5:32 ` Archie Pusaka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJQfnxHcag62zp4_0R9=KomC7FJB=xaRbmfaHsTp8JrOgkV9Pg@mail.gmail.com' \
    --to=apusaka@google.com \
    --cc=abhishekpandit@chromium.org \
    --cc=chromeos-bluetooth-upstreaming@chromium.org \
    --cc=drinkcat@chromium.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).