linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Barnabás Pőcze" <pobrn@protonmail.com>
To: Roderick Colenbrander <roderick@gaikai.com>
Cc: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	Chris Ye <lzye@google.com>,
	Roderick Colenbrander <roderick.colenbrander@sony.com>
Subject: Re: [PATCH 09/13] HID: playstation: add DualSense lightbar support
Date: Sun, 27 Dec 2020 14:41:01 +0000	[thread overview]
Message-ID: <_n_Seien29lcWzPT6LHN7MEtqlVZpJOBRKw-qe01hEhSGbKKL7cffbmSGPjZZIN8Q4B8fInhwChsV0JB70F-wqj44ZQILevS6y3FXYaDtw8=@protonmail.com> (raw)
In-Reply-To: <20201219062336.72568-10-roderick@gaikai.com>

Hi


2020. december 19., szombat 7:23 keltezéssel, Roderick Colenbrander írta:

> [...]
> diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
> index 0b62bcb28d8a..f8cf82a27d43 100644
> [...]
> +/* Create a DualSense/DualShock4 RGB lightbar represented by a multicolor LED. */
> +static struct led_classdev_mc *ps_lightbar_create(struct ps_device *ps_dev,
> +	int (*brightness_set)(struct led_classdev *, enum led_brightness))
> +{
> +	struct hid_device *hdev = ps_dev->hdev;
> +	struct led_classdev_mc *lightbar_mc_dev;
> +	struct mc_subled *mc_led_info;
> +	struct led_classdev *led_cdev;
> +	int ret;
> +
> +	lightbar_mc_dev = devm_kzalloc(&hdev->dev, sizeof(*lightbar_mc_dev), GFP_KERNEL);
> +	if (!lightbar_mc_dev)
> +		return ERR_PTR(-ENOMEM);
> +
> +	mc_led_info = devm_kzalloc(&hdev->dev, 3*sizeof(*mc_led_info), GFP_KERNEL);
> +	if (!mc_led_info)
> +		return ERR_PTR(-ENOMEM);
> +

Is there any reason why these are dynamically allocated?


> +	mc_led_info[0].color_index = LED_COLOR_ID_RED;
> +	mc_led_info[0].channel = 0;
> +	mc_led_info[1].color_index = LED_COLOR_ID_GREEN;
> +	mc_led_info[1].channel = 1;
> +	mc_led_info[2].color_index = LED_COLOR_ID_BLUE;
> +	mc_led_info[2].channel = 2;
> +
> +	lightbar_mc_dev->subled_info = mc_led_info;
> +	lightbar_mc_dev->num_colors = 3;
> +
> +	led_cdev = &lightbar_mc_dev->led_cdev;
> +	led_cdev->name = devm_kasprintf(&hdev->dev, GFP_KERNEL, "playstation::%pMR::rgb",
> +			ps_dev->mac_address);

I guess the double colons are used because the MAC address has ':' in it; but
as far as I know this doesn't follow the naming scheme for LED devices, so I'm
not sure if this is the best way to go about it.


> +	led_cdev->brightness = 255;
> +	led_cdev->max_brightness = 255;
> +	led_cdev->brightness_set_blocking = brightness_set;
> +
> +	ret = devm_led_classdev_multicolor_register(&hdev->dev, lightbar_mc_dev);
> +	if (ret < 0) {
> +		hid_err(hdev, "Cannot register multicolor LED device\n");
> +		return ERR_PTR(ret);
> +	}
> +
> +	return lightbar_mc_dev;
> +}
> [...]
> +static int dualsense_reset_leds(struct dualsense *ds)
> +{
> +	struct dualsense_output_report report;
> +	uint8_t *buf;
> +
> +	buf = kzalloc(sizeof(struct dualsense_output_report_bt), GFP_KERNEL);
> +	if (!buf)
> +		return -ENOMEM;
> +
> +	dualsense_init_output_report(ds, &report, buf);
> +	/* On Bluetooth the DualSense outputs an animation on the lightbar
> +	 * during startup and maintains a color afterwards. We need to explicitly
> +	 * reconfigure the lightbar before we can do any programming later on.
> +	 * In USB the lightbar is not on by default, but redoing the setup there
> +	 * doesn't hurt.
> +	 */
> +	report.common->valid_flag2 = DS_OUTPUT_VALID_FLAG2_LIGHTBAR_SETUP_CONTROL_ENABLE;
> +	report.common->lightbar_setup = 2; /* Fade light out. */

Maybe it'd be better to name that '2'?


> +	dualsense_send_output_report(ds, &report);
> +
> +	kfree(buf);
> +	return 0;
> +}
> [...]


Regards,
Barnabás Pőcze

  reply	other threads:[~2020-12-27 14:41 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-19  6:23 [PATCH 00/13] HID: new driver for PS5 'DualSense' controller Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 01/13] HID: playstation: initial DualSense USB support Roderick Colenbrander
2020-12-27 16:23   ` Barnabás Pőcze
2020-12-27 23:04     ` Roderick Colenbrander
2020-12-29 19:12       ` Barnabás Pőcze
2020-12-31  0:08   ` Barnabás Pőcze
2020-12-31  1:08     ` Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 02/13] HID: playstation: use DualSense MAC address as unique identifier Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 03/13] HID: playstation: add DualSense battery support Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 04/13] HID: playstation: add DualSense touchpad support Roderick Colenbrander
2020-12-26  2:14   ` Samuel Čavoj
2020-12-26 22:27     ` Roderick Colenbrander
2020-12-29 19:49   ` Barnabás Pőcze
2020-12-29 21:44     ` Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 05/13] HID: playstation: add DualSense accelerometer and gyroscope support Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 06/13] HID: playstation: track devices in list Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 07/13] HID: playstation: add DualSense Bluetooth support Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 08/13] HID: playstation: add DualSense classic rumble support Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 09/13] HID: playstation: add DualSense lightbar support Roderick Colenbrander
2020-12-27 14:41   ` Barnabás Pőcze [this message]
2020-12-28 21:26     ` Roderick Colenbrander
2020-12-29 18:59       ` Barnabás Pőcze
2020-12-29 19:54         ` Roderick Colenbrander
2020-12-29 20:22           ` Barnabás Pőcze
2020-12-19  6:23 ` [PATCH 10/13] HID: playstation: add microphone mute support for DualSense Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 11/13] HID: playstation: add DualSense player LEDs support Roderick Colenbrander
2020-12-26 19:27   ` Samuel Čavoj
2020-12-26 23:07     ` Roderick Colenbrander
2020-12-27 14:27   ` Barnabás Pőcze
2020-12-28 22:02     ` Roderick Colenbrander
2020-12-29 18:49       ` Barnabás Pőcze
2020-12-19  6:23 ` [PATCH 12/13] HID: playstation: DualSense set LEDs to default player id Roderick Colenbrander
2020-12-27  0:08   ` Samuel Čavoj
2020-12-27 23:07     ` Roderick Colenbrander
2020-12-19  6:23 ` [PATCH 13/13] HID: playstation: report DualSense hardware and firmware version Roderick Colenbrander
2020-12-27 17:06   ` Barnabás Pőcze
2020-12-27 22:21     ` Roderick Colenbrander
2020-12-27 22:27       ` Roderick Colenbrander
2020-12-27 22:37         ` Barnabás Pőcze
2020-12-28 22:45           ` Roderick Colenbrander
2020-12-29 15:10             ` Barnabás Pőcze
2020-12-19  8:38 ` [PATCH 00/13] HID: new driver for PS5 'DualSense' controller Bastien Nocera
2020-12-19 22:39   ` Roderick.Colenbrander

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='_n_Seien29lcWzPT6LHN7MEtqlVZpJOBRKw-qe01hEhSGbKKL7cffbmSGPjZZIN8Q4B8fInhwChsV0JB70F-wqj44ZQILevS6y3FXYaDtw8=@protonmail.com' \
    --to=pobrn@protonmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=lzye@google.com \
    --cc=roderick.colenbrander@sony.com \
    --cc=roderick@gaikai.com \
    --subject='Re: [PATCH 09/13] HID: playstation: add DualSense lightbar support' \
    /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

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox