linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/9] Support light color temperature and chromaticity
@ 2023-09-19  8:10 Basavaraj Natikar
  2023-09-19  8:10 ` [PATCH v2 1/9] iio: hid-sensor-als: Use channel index to support more hub attributes Basavaraj Natikar
                   ` (10 more replies)
  0 siblings, 11 replies; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-19  8:10 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio
  Cc: Basavaraj Natikar

This series adds support for light color temperature and chromaticity.

v1->v2:
*Rename the series.
*Rename als_illum to als channel as it supports other channels.
*Update patch description to include same reading for the two existing
 channels to use channel index to support more hub attributes.
*Keep line length under 80chars in hid-sensor-als.
*Add new channel type IIO_COLORTEMP.
*Update patch description and its subject to add channel type for 
 chromaticity. 

Basavaraj Natikar (9):
  iio: hid-sensor-als: Use channel index to support more hub attributes
  iio: Add channel type light color temperature
  iio: hid-sensor-als: Add light color temperature support
  HID: amd_sfh: Add support for light color temperature
  HID: amd_sfh: Add support for SFH1.1 light color temperature
  iio: Add channel type for chromaticity
  iio: hid-sensor-als: Add light chromaticity support
  HID: amd_sfh: Add light chromaticity support
  HID: amd_sfh: Add light chromaticity for SFH1.1

 Documentation/ABI/testing/sysfs-bus-iio       |  15 ++
 .../hid_descriptor/amd_sfh_hid_desc.c         |   7 +
 .../hid_descriptor/amd_sfh_hid_desc.h         |   3 +
 .../hid_descriptor/amd_sfh_hid_report_desc.h  |  21 +++
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c |   9 ++
 .../amd-sfh-hid/sfh1_1/amd_sfh_interface.h    |  15 ++
 drivers/iio/industrialio-core.c               |   2 +
 drivers/iio/light/hid-sensor-als.c            | 130 +++++++++++++++---
 include/linux/hid-sensor-ids.h                |   4 +
 include/uapi/linux/iio/types.h                |   2 +
 tools/iio/iio_event_monitor.c                 |   3 +
 11 files changed, 195 insertions(+), 16 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH v2 1/9] iio: hid-sensor-als: Use channel index to support more hub attributes
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
@ 2023-09-19  8:10 ` Basavaraj Natikar
  2023-09-20 16:59   ` srinivas pandruvada
  2023-09-19  8:10 ` [PATCH v2 2/9] iio: Add channel type light color temperature Basavaraj Natikar
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-19  8:10 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio
  Cc: Basavaraj Natikar

Sensor hub attributes can be extended to support more channels. Repeat
the reading for the two existing channels and store them separately. It
still operates in the same manner as before where there was just one
entry. So in order to support more sensor hub attributes for ALS use
channel index to get specific sensor hub attributes.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 drivers/iio/light/hid-sensor-als.c | 38 ++++++++++++++++--------------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index eb1aedad7edc..efb1f8862b28 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -24,7 +24,7 @@ enum {
 struct als_state {
 	struct hid_sensor_hub_callbacks callbacks;
 	struct hid_sensor_common common_attributes;
-	struct hid_sensor_hub_attribute_info als_illum;
+	struct hid_sensor_hub_attribute_info als[CHANNEL_SCAN_INDEX_MAX];
 	struct {
 		u32 illum[CHANNEL_SCAN_INDEX_MAX];
 		u64 timestamp __aligned(8);
@@ -99,8 +99,8 @@ static int als_read_raw(struct iio_dev *indio_dev,
 		switch (chan->scan_index) {
 		case  CHANNEL_SCAN_INDEX_INTENSITY:
 		case  CHANNEL_SCAN_INDEX_ILLUM:
-			report_id = als_state->als_illum.report_id;
-			min = als_state->als_illum.logical_minimum;
+			report_id = als_state->als[chan->scan_index].report_id;
+			min = als_state->als[chan->scan_index].logical_minimum;
 			address = HID_USAGE_SENSOR_LIGHT_ILLUM;
 			break;
 		default:
@@ -242,22 +242,24 @@ static int als_parse_report(struct platform_device *pdev,
 				struct als_state *st)
 {
 	int ret;
+	int i;
+
+	for (i = 0; i <= CHANNEL_SCAN_INDEX_ILLUM; ++i) {
+		ret = sensor_hub_input_get_attribute_info(hsdev,
+						HID_INPUT_REPORT,
+						usage_id,
+						HID_USAGE_SENSOR_LIGHT_ILLUM,
+						&st->als[i]);
+		if (ret < 0)
+			return ret;
+		als_adjust_channel_bit_mask(channels, i, st->als[i].size);
+
+		dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index,
+			st->als[i].report_id);
+	}
 
-	ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT,
-			usage_id,
-			HID_USAGE_SENSOR_LIGHT_ILLUM,
-			&st->als_illum);
-	if (ret < 0)
-		return ret;
-	als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_INTENSITY,
-				    st->als_illum.size);
-	als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_ILLUM,
-					st->als_illum.size);
-
-	dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index,
-			st->als_illum.report_id);
-
-	st->scale_precision = hid_sensor_format_scale(usage_id, &st->als_illum,
+	st->scale_precision = hid_sensor_format_scale(usage_id,
+				&st->als[CHANNEL_SCAN_INDEX_INTENSITY],
 				&st->scale_pre_decml, &st->scale_post_decml);
 
 	return ret;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 2/9] iio: Add channel type light color temperature
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
  2023-09-19  8:10 ` [PATCH v2 1/9] iio: hid-sensor-als: Use channel index to support more hub attributes Basavaraj Natikar
@ 2023-09-19  8:10 ` Basavaraj Natikar
  2023-09-19  8:10 ` [PATCH v2 3/9] iio: hid-sensor-als: Add light color temperature support Basavaraj Natikar
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-19  8:10 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio
  Cc: Basavaraj Natikar

In most cases, ambient color sensors also support light color
temperature, which is measured in kelvin. Thus, add channel type light
color temperature.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 Documentation/ABI/testing/sysfs-bus-iio | 7 +++++++
 drivers/iio/industrialio-core.c         | 1 +
 include/uapi/linux/iio/types.h          | 1 +
 tools/iio/iio_event_monitor.c           | 2 ++
 4 files changed, 11 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index a2854dc9a839..4cf7ed9ca57b 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -2179,3 +2179,10 @@ Contact:	linux-iio@vger.kernel.org
 Description:
 		Number of conditions that must occur, during a running
 		period, before an event is generated.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_colortemp_raw
+KernelVersion:	6.7
+Contact:	linux-iio@vger.kernel.org
+Description:
+		Represents light color temperature, which measures light color
+		temperature in Kelvin.
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index d752e9c0499b..cba942cadf97 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -90,6 +90,7 @@ static const char * const iio_chan_type_name_spec[] = {
 	[IIO_POSITIONRELATIVE]  = "positionrelative",
 	[IIO_PHASE] = "phase",
 	[IIO_MASSCONCENTRATION] = "massconcentration",
+	[IIO_COLORTEMP] = "colortemp",
 };
 
 static const char * const iio_modifier_names[] = {
diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
index c79f2f046a0b..08c20e540c13 100644
--- a/include/uapi/linux/iio/types.h
+++ b/include/uapi/linux/iio/types.h
@@ -47,6 +47,7 @@ enum iio_chan_type {
 	IIO_POSITIONRELATIVE,
 	IIO_PHASE,
 	IIO_MASSCONCENTRATION,
+	IIO_COLORTEMP,
 };
 
 enum iio_modifier {
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index 0a5c2bb60030..a63741e43ddf 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -59,6 +59,7 @@ static const char * const iio_chan_type_name_spec[] = {
 	[IIO_POSITIONRELATIVE] = "positionrelative",
 	[IIO_PHASE] = "phase",
 	[IIO_MASSCONCENTRATION] = "massconcentration",
+	[IIO_COLORTEMP] = "colortemp",
 };
 
 static const char * const iio_ev_type_text[] = {
@@ -173,6 +174,7 @@ static bool event_is_known(struct iio_event_data *event)
 	case IIO_POSITIONRELATIVE:
 	case IIO_PHASE:
 	case IIO_MASSCONCENTRATION:
+	case IIO_COLORTEMP:
 		break;
 	default:
 		return false;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 3/9] iio: hid-sensor-als: Add light color temperature support
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
  2023-09-19  8:10 ` [PATCH v2 1/9] iio: hid-sensor-als: Use channel index to support more hub attributes Basavaraj Natikar
  2023-09-19  8:10 ` [PATCH v2 2/9] iio: Add channel type light color temperature Basavaraj Natikar
@ 2023-09-19  8:10 ` Basavaraj Natikar
  2023-09-20 17:00   ` srinivas pandruvada
  2023-09-19  8:10 ` [PATCH v2 4/9] HID: amd_sfh: Add support for light color temperature Basavaraj Natikar
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-19  8:10 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio
  Cc: Basavaraj Natikar

In most cases, ambient color sensors also support light color temperature.
As a result, add support of light color temperature.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 drivers/iio/light/hid-sensor-als.c | 37 ++++++++++++++++++++++++++++--
 include/linux/hid-sensor-ids.h     |  1 +
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index efb1f8862b28..16a3f1941c27 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -14,8 +14,9 @@
 #include "../common/hid-sensors/hid-sensor-trigger.h"
 
 enum {
-	CHANNEL_SCAN_INDEX_INTENSITY = 0,
-	CHANNEL_SCAN_INDEX_ILLUM = 1,
+	CHANNEL_SCAN_INDEX_INTENSITY,
+	CHANNEL_SCAN_INDEX_ILLUM,
+	CHANNEL_SCAN_INDEX_COLOR_TEMP,
 	CHANNEL_SCAN_INDEX_MAX
 };
 
@@ -65,6 +66,16 @@ static const struct iio_chan_spec als_channels[] = {
 		BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
 		.scan_index = CHANNEL_SCAN_INDEX_ILLUM,
 	},
+	{
+		.type = IIO_COLORTEMP,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
+		BIT(IIO_CHAN_INFO_SCALE) |
+		BIT(IIO_CHAN_INFO_SAMP_FREQ) |
+		BIT(IIO_CHAN_INFO_HYSTERESIS) |
+		BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
+		.scan_index = CHANNEL_SCAN_INDEX_COLOR_TEMP,
+	},
 	IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
 };
 
@@ -103,6 +114,11 @@ static int als_read_raw(struct iio_dev *indio_dev,
 			min = als_state->als[chan->scan_index].logical_minimum;
 			address = HID_USAGE_SENSOR_LIGHT_ILLUM;
 			break;
+		case  CHANNEL_SCAN_INDEX_COLOR_TEMP:
+			report_id = als_state->als[chan->scan_index].report_id;
+			min = als_state->als[chan->scan_index].logical_minimum;
+			address = HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE;
+			break;
 		default:
 			report_id = -1;
 			break;
@@ -223,6 +239,10 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev,
 		als_state->scan.illum[CHANNEL_SCAN_INDEX_ILLUM] = sample_data;
 		ret = 0;
 		break;
+	case HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE:
+		als_state->scan.illum[CHANNEL_SCAN_INDEX_COLOR_TEMP] = sample_data;
+		ret = 0;
+		break;
 	case HID_USAGE_SENSOR_TIME_TIMESTAMP:
 		als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes,
 								    *(s64 *)raw_data);
@@ -258,6 +278,19 @@ static int als_parse_report(struct platform_device *pdev,
 			st->als[i].report_id);
 	}
 
+	ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT,
+				usage_id,
+				HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE,
+				&st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP]);
+	if (ret < 0)
+		return ret;
+	als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_COLOR_TEMP,
+				st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size);
+
+	dev_dbg(&pdev->dev, "als %x:%x\n",
+		st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index,
+		st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id);
+
 	st->scale_precision = hid_sensor_format_scale(usage_id,
 				&st->als[CHANNEL_SCAN_INDEX_INTENSITY],
 				&st->scale_pre_decml, &st->scale_post_decml);
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index 13b1e65fbdcc..8af4fb3e0254 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -21,6 +21,7 @@
 #define HID_USAGE_SENSOR_ALS					0x200041
 #define HID_USAGE_SENSOR_DATA_LIGHT				0x2004d0
 #define HID_USAGE_SENSOR_LIGHT_ILLUM				0x2004d1
+#define HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE		0x2004d2
 
 /* PROX (200011) */
 #define HID_USAGE_SENSOR_PROX                                   0x200011
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 4/9] HID: amd_sfh: Add support for light color temperature
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
                   ` (2 preceding siblings ...)
  2023-09-19  8:10 ` [PATCH v2 3/9] iio: hid-sensor-als: Add light color temperature support Basavaraj Natikar
@ 2023-09-19  8:10 ` Basavaraj Natikar
  2023-09-20 15:25   ` Jiri Kosina
  2023-09-19  8:10 ` [PATCH v2 5/9] HID: amd_sfh: Add support for SFH1.1 " Basavaraj Natikar
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-19  8:10 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio
  Cc: Basavaraj Natikar

In most cases, ambient color sensors also support light color temperature.
As a result, add support of light color temperature.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c  | 4 ++++
 drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h  | 1 +
 .../amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h   | 7 +++++++
 3 files changed, 12 insertions(+)

diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
index 8716a05950c8..b7e732ec4806 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
@@ -257,6 +257,10 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id,
 		else
 			als_input.illuminance_value =
 				(int)sensor_virt_addr[0] / AMD_SFH_FW_MULTIPLIER;
+
+		if (sensor_idx == ACS_IDX)
+			als_input.light_color_temp = sensor_virt_addr[1];
+
 		report_size = sizeof(als_input);
 		memcpy(input_report, &als_input, sizeof(als_input));
 		break;
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
index ebd55675eb62..a7fc50deca4d 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
@@ -99,6 +99,7 @@ struct als_input_report {
 	struct common_input_property common_property;
 	/* values specific to this sensor */
 	int illuminance_value;
+	int light_color_temp;
 } __packed;
 
 struct hpd_feature_report {
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
index 697f2791ea9c..26e994e54ded 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
@@ -641,6 +641,13 @@ static const u8 als_report_descriptor[] = {
 0x75, 32,		/* HID report size(32) */
 0x95, 1,		/* HID report count (1) */
 0X81, 0x02,		/* HID Input (Data_Arr_Abs) */
+0x0A, 0xD2, 0x04,	/* HID usage sensor data light temperature */
+0x17, 0x00, 0x00, 0x01, 0x80,	 /* HID logical Min_32 */
+0x27, 0xFF, 0xFF, 0xFF, 0x7F,	 /* HID logical Max_32 */
+0x55, 0x0,		/* HID unit exponent(0x0) */
+0x75, 32,		/* HID report size(32) */
+0x95, 1,		/* HID report count (1) */
+0X81, 0x02,		/* HID Input (Data_Arr_Abs) */
 0xC0			/* HID end collection */
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 5/9] HID: amd_sfh: Add support for SFH1.1 light color temperature
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
                   ` (3 preceding siblings ...)
  2023-09-19  8:10 ` [PATCH v2 4/9] HID: amd_sfh: Add support for light color temperature Basavaraj Natikar
@ 2023-09-19  8:10 ` Basavaraj Natikar
  2023-09-20 15:25   ` Jiri Kosina
  2023-09-19  8:10 ` [PATCH v2 6/9] iio: Add channel type for chromaticity Basavaraj Natikar
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-19  8:10 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio
  Cc: Basavaraj Natikar

In most cases, ambient color sensors also support light color temperature.
As a result, add support of light color temperature for SFH1.1.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c      |  6 ++++++
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 13 +++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
index 06bdcf072d10..f100aaafa167 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
@@ -188,6 +188,7 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
 	struct sfh_mag_data mag_data;
 	struct sfh_als_data als_data;
 	struct hpd_status hpdstatus;
+	struct sfh_base_info binfo;
 	void __iomem *sensoraddr;
 	u8 report_size = 0;
 
@@ -235,6 +236,11 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
 		memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data));
 		get_common_inputs(&als_input.common_property, report_id);
 		als_input.illuminance_value = float_to_int(als_data.lux);
+
+		memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info));
+		if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2)
+			als_input.light_color_temp = als_data.light_color_temp;
+
 		report_size = sizeof(als_input);
 		memcpy(input_report, &als_input, sizeof(als_input));
 		break;
diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
index 9d31d5b510eb..6f6f5db150c3 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
@@ -88,6 +88,16 @@ struct sfh_sensor_list {
 	};
 };
 
+struct sfh_sensor_prop {
+	union {
+		u32 sprop;
+		struct {
+			u32 elist	: 16;
+			u32 feat	: 16;
+		} sf;
+	};
+};
+
 struct sfh_base_info {
 	union {
 		u32 sfh_base[24];
@@ -95,6 +105,8 @@ struct sfh_base_info {
 			struct sfh_platform_info plat_info;
 			struct sfh_firmware_info  fw_info;
 			struct sfh_sensor_list s_list;
+			u32 rsvd;
+			struct sfh_sensor_prop s_prop[16];
 		} sbase;
 	};
 };
@@ -134,6 +146,7 @@ struct sfh_mag_data {
 struct sfh_als_data {
 	struct sfh_common_data commondata;
 	u32 lux;
+	u32 light_color_temp;
 };
 
 struct hpd_status {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 6/9] iio: Add channel type for chromaticity
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
                   ` (4 preceding siblings ...)
  2023-09-19  8:10 ` [PATCH v2 5/9] HID: amd_sfh: Add support for SFH1.1 " Basavaraj Natikar
@ 2023-09-19  8:10 ` Basavaraj Natikar
  2023-09-24 12:31   ` Jonathan Cameron
  2023-09-19  8:10 ` [PATCH v2 7/9] iio: hid-sensor-als: Add light chromaticity support Basavaraj Natikar
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-19  8:10 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio
  Cc: Basavaraj Natikar

In most cases, ambient color sensors also support the x and y light
colors, which represent the coordinates on the CIE 1931 chromaticity
diagram. Thus, add channel type for chromaticity.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 Documentation/ABI/testing/sysfs-bus-iio | 8 ++++++++
 drivers/iio/industrialio-core.c         | 1 +
 include/uapi/linux/iio/types.h          | 1 +
 tools/iio/iio_event_monitor.c           | 1 +
 4 files changed, 11 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 4cf7ed9ca57b..0c9389ad3709 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -2186,3 +2186,11 @@ Contact:	linux-iio@vger.kernel.org
 Description:
 		Represents light color temperature, which measures light color
 		temperature in Kelvin.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_chromaticity_x_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_chromaticity_y_raw
+KernelVersion:	6.7
+Contact:	linux-iio@vger.kernel.org
+Description:
+		The x and y light color coordinate on the CIE 1931 chromaticity
+		diagram.
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index cba942cadf97..6dc4d2b296bb 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -91,6 +91,7 @@ static const char * const iio_chan_type_name_spec[] = {
 	[IIO_PHASE] = "phase",
 	[IIO_MASSCONCENTRATION] = "massconcentration",
 	[IIO_COLORTEMP] = "colortemp",
+	[IIO_CHROMATICITY] = "chromaticity",
 };
 
 static const char * const iio_modifier_names[] = {
diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
index 08c20e540c13..4832c611c027 100644
--- a/include/uapi/linux/iio/types.h
+++ b/include/uapi/linux/iio/types.h
@@ -48,6 +48,7 @@ enum iio_chan_type {
 	IIO_PHASE,
 	IIO_MASSCONCENTRATION,
 	IIO_COLORTEMP,
+	IIO_CHROMATICITY,
 };
 
 enum iio_modifier {
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index a63741e43ddf..5edacc358c5d 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -175,6 +175,7 @@ static bool event_is_known(struct iio_event_data *event)
 	case IIO_PHASE:
 	case IIO_MASSCONCENTRATION:
 	case IIO_COLORTEMP:
+	case IIO_CHROMATICITY:
 		break;
 	default:
 		return false;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 7/9] iio: hid-sensor-als: Add light chromaticity support
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
                   ` (5 preceding siblings ...)
  2023-09-19  8:10 ` [PATCH v2 6/9] iio: Add channel type for chromaticity Basavaraj Natikar
@ 2023-09-19  8:10 ` Basavaraj Natikar
  2023-09-20 17:10   ` srinivas pandruvada
  2023-09-19  8:10 ` [PATCH v2 8/9] HID: amd_sfh: " Basavaraj Natikar
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-19  8:10 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio
  Cc: Basavaraj Natikar

In most cases, ambient color sensors also support the x and y light
colors, which represent the coordinates on the CIE 1931 chromaticity
diagram. Thus, add light chromaticity x and y.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 drivers/iio/light/hid-sensor-als.c | 63 ++++++++++++++++++++++++++++++
 include/linux/hid-sensor-ids.h     |  3 ++
 2 files changed, 66 insertions(+)

diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 16a3f1941c27..c9d114ff080a 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -17,6 +17,8 @@ enum {
 	CHANNEL_SCAN_INDEX_INTENSITY,
 	CHANNEL_SCAN_INDEX_ILLUM,
 	CHANNEL_SCAN_INDEX_COLOR_TEMP,
+	CHANNEL_SCAN_INDEX_CHROMATICITY_X,
+	CHANNEL_SCAN_INDEX_CHROMATICITY_Y,
 	CHANNEL_SCAN_INDEX_MAX
 };
 
@@ -76,6 +78,30 @@ static const struct iio_chan_spec als_channels[] = {
 		BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
 		.scan_index = CHANNEL_SCAN_INDEX_COLOR_TEMP,
 	},
+	{
+		.type = IIO_CHROMATICITY,
+		.modified = 1,
+		.channel2 = IIO_MOD_X,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
+		BIT(IIO_CHAN_INFO_SCALE) |
+		BIT(IIO_CHAN_INFO_SAMP_FREQ) |
+		BIT(IIO_CHAN_INFO_HYSTERESIS) |
+		BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
+		.scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X,
+	},
+	{
+		.type = IIO_CHROMATICITY,
+		.modified = 1,
+		.channel2 = IIO_MOD_Y,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
+		BIT(IIO_CHAN_INFO_SCALE) |
+		BIT(IIO_CHAN_INFO_SAMP_FREQ) |
+		BIT(IIO_CHAN_INFO_HYSTERESIS) |
+		BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
+		.scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_Y,
+	},
 	IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
 };
 
@@ -119,6 +145,16 @@ static int als_read_raw(struct iio_dev *indio_dev,
 			min = als_state->als[chan->scan_index].logical_minimum;
 			address = HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE;
 			break;
+		case  CHANNEL_SCAN_INDEX_CHROMATICITY_X:
+			report_id = als_state->als[chan->scan_index].report_id;
+			min = als_state->als[chan->scan_index].logical_minimum;
+			address = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X;
+			break;
+		case  CHANNEL_SCAN_INDEX_CHROMATICITY_Y:
+			report_id = als_state->als[chan->scan_index].report_id;
+			min = als_state->als[chan->scan_index].logical_minimum;
+			address = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y;
+			break;
 		default:
 			report_id = -1;
 			break;
@@ -243,6 +279,14 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev,
 		als_state->scan.illum[CHANNEL_SCAN_INDEX_COLOR_TEMP] = sample_data;
 		ret = 0;
 		break;
+	case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X:
+		als_state->scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_X] = sample_data;
+		ret = 0;
+		break;
+	case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y:
+		als_state->scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_Y] = sample_data;
+		ret = 0;
+		break;
 	case HID_USAGE_SENSOR_TIME_TIMESTAMP:
 		als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes,
 								    *(s64 *)raw_data);
@@ -291,6 +335,25 @@ static int als_parse_report(struct platform_device *pdev,
 		st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index,
 		st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id);
 
+	for (i = 0; i < 2; i++) {
+		int next_scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X + i;
+
+		ret = sensor_hub_input_get_attribute_info(hsdev,
+				HID_INPUT_REPORT, usage_id,
+				HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X + i,
+				&st->als[next_scan_index]);
+		if (ret < 0)
+			return ret;
+
+		als_adjust_channel_bit_mask(channels,
+					CHANNEL_SCAN_INDEX_CHROMATICITY_X + i,
+					st->als[next_scan_index].size);
+
+		dev_dbg(&pdev->dev, "als %x:%x\n",
+			st->als[next_scan_index].index,
+			st->als[next_scan_index].report_id);
+	}
+
 	st->scale_precision = hid_sensor_format_scale(usage_id,
 				&st->als[CHANNEL_SCAN_INDEX_INTENSITY],
 				&st->scale_pre_decml, &st->scale_post_decml);
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index 8af4fb3e0254..6730ee900ee1 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -22,6 +22,9 @@
 #define HID_USAGE_SENSOR_DATA_LIGHT				0x2004d0
 #define HID_USAGE_SENSOR_LIGHT_ILLUM				0x2004d1
 #define HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE		0x2004d2
+#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY			0x2004d3
+#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X			0x2004d4
+#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y			0x2004d5
 
 /* PROX (200011) */
 #define HID_USAGE_SENSOR_PROX                                   0x200011
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 8/9] HID: amd_sfh: Add light chromaticity support
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
                   ` (6 preceding siblings ...)
  2023-09-19  8:10 ` [PATCH v2 7/9] iio: hid-sensor-als: Add light chromaticity support Basavaraj Natikar
@ 2023-09-19  8:10 ` Basavaraj Natikar
  2023-09-20 15:25   ` Jiri Kosina
  2023-09-19  8:10 ` [PATCH v2 9/9] HID: amd_sfh: Add light chromaticity for SFH1.1 Basavaraj Natikar
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-19  8:10 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio
  Cc: Basavaraj Natikar

In most cases, ambient color sensors also support the x and y light
colors, which represent the coordinates on the CIE 1931 chromaticity
diagram. Thus, add light chromaticity x and y.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 .../amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c  |  5 ++++-
 .../amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h  |  2 ++
 .../hid_descriptor/amd_sfh_hid_report_desc.h       | 14 ++++++++++++++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
index b7e732ec4806..ef1f9be8b893 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
@@ -258,8 +258,11 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id,
 			als_input.illuminance_value =
 				(int)sensor_virt_addr[0] / AMD_SFH_FW_MULTIPLIER;
 
-		if (sensor_idx == ACS_IDX)
+		if (sensor_idx == ACS_IDX) {
 			als_input.light_color_temp = sensor_virt_addr[1];
+			als_input.chromaticity_x_value = sensor_virt_addr[2];
+			als_input.chromaticity_y_value = sensor_virt_addr[3];
+		}
 
 		report_size = sizeof(als_input);
 		memcpy(input_report, &als_input, sizeof(als_input));
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
index a7fc50deca4d..882434b1501f 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
@@ -100,6 +100,8 @@ struct als_input_report {
 	/* values specific to this sensor */
 	int illuminance_value;
 	int light_color_temp;
+	int chromaticity_x_value;
+	int chromaticity_y_value;
 } __packed;
 
 struct hpd_feature_report {
diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
index 26e994e54ded..67ec2d6a417d 100644
--- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
+++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
@@ -648,6 +648,20 @@ static const u8 als_report_descriptor[] = {
 0x75, 32,		/* HID report size(32) */
 0x95, 1,		/* HID report count (1) */
 0X81, 0x02,		/* HID Input (Data_Arr_Abs) */
+0x0A, 0xD4, 0x04,       /* HID usage sensor data light chromaticity_x */
+0x17, 0x00, 0x00, 0x01, 0x80,	 /* HID logical Min_32 */
+0x27, 0xFF, 0xFF, 0xFF, 0x7F,	 /* HID logical Max_32 */
+0x55, 0x0,		/* HID unit exponent(0x0) */
+0x75, 32,		/* HID report size(32) */
+0x95, 1,		/* HID report count(1) */
+0X81, 0x02,		/* HID Input (Data_Var_Abs) */
+0x0A, 0xD5, 0x04,       /* HID usage sensor data light chromaticity_y */
+0x17, 0x00, 0x00, 0x01, 0x80,	 /* HID logical Min_32 */
+0x27, 0xFF, 0xFF, 0xFF, 0x7F,	 /* HID logical Max_32 */
+0x55, 0x0,		/* HID unit exponent(0x0) */
+0x75, 32,		/* HID report size(32) */
+0x95, 1,		/* HID report count (1) */
+0X81, 0x02,		/* HID Input (Data_Var_Abs) */
 0xC0			/* HID end collection */
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH v2 9/9] HID: amd_sfh: Add light chromaticity for SFH1.1
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
                   ` (7 preceding siblings ...)
  2023-09-19  8:10 ` [PATCH v2 8/9] HID: amd_sfh: " Basavaraj Natikar
@ 2023-09-19  8:10 ` Basavaraj Natikar
  2023-09-20 15:26   ` Jiri Kosina
  2023-09-20 14:13 ` [PATCH v2 0/9] Support light color temperature and chromaticity Jiri Kosina
  2023-12-06 23:39 ` Thomas Weißschuh
  10 siblings, 1 reply; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-19  8:10 UTC (permalink / raw)
  To: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio
  Cc: Basavaraj Natikar

In most cases, ambient color sensors also support the x and y light
colors, which represent the coordinates on the CIE 1931 chromaticity
diagram. Thus, add light chromaticity x and y for SFH1.1.

Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
---
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c      | 5 ++++-
 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
index f100aaafa167..8a037de08e92 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
@@ -238,8 +238,11 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
 		als_input.illuminance_value = float_to_int(als_data.lux);
 
 		memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info));
-		if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2)
+		if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2) {
 			als_input.light_color_temp = als_data.light_color_temp;
+			als_input.chromaticity_x_value = float_to_int(als_data.chromaticity_x);
+			als_input.chromaticity_y_value = float_to_int(als_data.chromaticity_y);
+		}
 
 		report_size = sizeof(als_input);
 		memcpy(input_report, &als_input, sizeof(als_input));
diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
index 6f6f5db150c3..656c3e95ef8c 100644
--- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
+++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
@@ -147,6 +147,8 @@ struct sfh_als_data {
 	struct sfh_common_data commondata;
 	u32 lux;
 	u32 light_color_temp;
+	u32 chromaticity_x;
+	u32 chromaticity_y;
 };
 
 struct hpd_status {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 0/9] Support light color temperature and chromaticity
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
                   ` (8 preceding siblings ...)
  2023-09-19  8:10 ` [PATCH v2 9/9] HID: amd_sfh: Add light chromaticity for SFH1.1 Basavaraj Natikar
@ 2023-09-20 14:13 ` Jiri Kosina
  2023-09-20 15:23   ` Basavaraj Natikar
  2023-12-06 23:39 ` Thomas Weißschuh
  10 siblings, 1 reply; 27+ messages in thread
From: Jiri Kosina @ 2023-09-20 14:13 UTC (permalink / raw)
  To: Basavaraj Natikar
  Cc: benjamin.tissoires, jic23, lars, srinivas.pandruvada, linux-input,
	linux-iio

On Tue, 19 Sep 2023, Basavaraj Natikar wrote:

> This series adds support for light color temperature and chromaticity.
> 
> v1->v2:
> *Rename the series.
> *Rename als_illum to als channel as it supports other channels.
> *Update patch description to include same reading for the two existing
>  channels to use channel index to support more hub attributes.
> *Keep line length under 80chars in hid-sensor-als.
> *Add new channel type IIO_COLORTEMP.
> *Update patch description and its subject to add channel type for 
>  chromaticity. 
> 
> Basavaraj Natikar (9):
>   iio: hid-sensor-als: Use channel index to support more hub attributes
>   iio: Add channel type light color temperature
>   iio: hid-sensor-als: Add light color temperature support
>   HID: amd_sfh: Add support for light color temperature
>   HID: amd_sfh: Add support for SFH1.1 light color temperature
>   iio: Add channel type for chromaticity
>   iio: hid-sensor-als: Add light chromaticity support
>   HID: amd_sfh: Add light chromaticity support
>   HID: amd_sfh: Add light chromaticity for SFH1.1
> 
>  Documentation/ABI/testing/sysfs-bus-iio       |  15 ++
>  .../hid_descriptor/amd_sfh_hid_desc.c         |   7 +
>  .../hid_descriptor/amd_sfh_hid_desc.h         |   3 +
>  .../hid_descriptor/amd_sfh_hid_report_desc.h  |  21 +++
>  drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c |   9 ++
>  .../amd-sfh-hid/sfh1_1/amd_sfh_interface.h    |  15 ++
>  drivers/iio/industrialio-core.c               |   2 +
>  drivers/iio/light/hid-sensor-als.c            | 130 +++++++++++++++---
>  include/linux/hid-sensor-ids.h                |   4 +
>  include/uapi/linux/iio/types.h                |   2 +
>  tools/iio/iio_event_monitor.c                 |   3 +
>  11 files changed, 195 insertions(+), 16 deletions(-)

I believe this should go through Jonathan's tree as a whole, right?

Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 0/9] Support light color temperature and chromaticity
  2023-09-20 14:13 ` [PATCH v2 0/9] Support light color temperature and chromaticity Jiri Kosina
@ 2023-09-20 15:23   ` Basavaraj Natikar
  2023-09-24 12:42     ` Jonathan Cameron
  0 siblings, 1 reply; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-20 15:23 UTC (permalink / raw)
  To: Jiri Kosina, Basavaraj Natikar
  Cc: benjamin.tissoires, jic23, lars, srinivas.pandruvada, linux-input,
	linux-iio


On 9/20/2023 7:43 PM, Jiri Kosina wrote:
> On Tue, 19 Sep 2023, Basavaraj Natikar wrote:
>
>> This series adds support for light color temperature and chromaticity.
>>
>> v1->v2:
>> *Rename the series.
>> *Rename als_illum to als channel as it supports other channels.
>> *Update patch description to include same reading for the two existing
>>  channels to use channel index to support more hub attributes.
>> *Keep line length under 80chars in hid-sensor-als.
>> *Add new channel type IIO_COLORTEMP.
>> *Update patch description and its subject to add channel type for 
>>  chromaticity. 
>>
>> Basavaraj Natikar (9):
>>   iio: hid-sensor-als: Use channel index to support more hub attributes
>>   iio: Add channel type light color temperature
>>   iio: hid-sensor-als: Add light color temperature support
>>   HID: amd_sfh: Add support for light color temperature
>>   HID: amd_sfh: Add support for SFH1.1 light color temperature
>>   iio: Add channel type for chromaticity
>>   iio: hid-sensor-als: Add light chromaticity support
>>   HID: amd_sfh: Add light chromaticity support
>>   HID: amd_sfh: Add light chromaticity for SFH1.1
>>
>>  Documentation/ABI/testing/sysfs-bus-iio       |  15 ++
>>  .../hid_descriptor/amd_sfh_hid_desc.c         |   7 +
>>  .../hid_descriptor/amd_sfh_hid_desc.h         |   3 +
>>  .../hid_descriptor/amd_sfh_hid_report_desc.h  |  21 +++
>>  drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c |   9 ++
>>  .../amd-sfh-hid/sfh1_1/amd_sfh_interface.h    |  15 ++
>>  drivers/iio/industrialio-core.c               |   2 +
>>  drivers/iio/light/hid-sensor-als.c            | 130 +++++++++++++++---
>>  include/linux/hid-sensor-ids.h                |   4 +
>>  include/uapi/linux/iio/types.h                |   2 +
>>  tools/iio/iio_event_monitor.c                 |   3 +
>>  11 files changed, 195 insertions(+), 16 deletions(-)
> I believe this should go through Jonathan's tree as a whole, right?

Yes, this should go through Jonathan's tree as a whole.
If you don't have concerns, can you please ack HID amd_sfh changes?

Thanks,
--
Basavaraj


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 4/9] HID: amd_sfh: Add support for light color temperature
  2023-09-19  8:10 ` [PATCH v2 4/9] HID: amd_sfh: Add support for light color temperature Basavaraj Natikar
@ 2023-09-20 15:25   ` Jiri Kosina
  0 siblings, 0 replies; 27+ messages in thread
From: Jiri Kosina @ 2023-09-20 15:25 UTC (permalink / raw)
  To: Basavaraj Natikar
  Cc: benjamin.tissoires, jic23, lars, srinivas.pandruvada, linux-input,
	linux-iio

On Tue, 19 Sep 2023, Basavaraj Natikar wrote:

> In most cases, ambient color sensors also support light color temperature.
> As a result, add support of light color temperature.
> 
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

Acked-by: Jiri Kosina <jkosina@suse.cz>

> ---
>  drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c  | 4 ++++
>  drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h  | 1 +
>  .../amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h   | 7 +++++++
>  3 files changed, 12 insertions(+)
> 
> diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
> index 8716a05950c8..b7e732ec4806 100644
> --- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
> +++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
> @@ -257,6 +257,10 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id,
>  		else
>  			als_input.illuminance_value =
>  				(int)sensor_virt_addr[0] / AMD_SFH_FW_MULTIPLIER;
> +
> +		if (sensor_idx == ACS_IDX)
> +			als_input.light_color_temp = sensor_virt_addr[1];
> +
>  		report_size = sizeof(als_input);
>  		memcpy(input_report, &als_input, sizeof(als_input));
>  		break;
> diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
> index ebd55675eb62..a7fc50deca4d 100644
> --- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
> +++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
> @@ -99,6 +99,7 @@ struct als_input_report {
>  	struct common_input_property common_property;
>  	/* values specific to this sensor */
>  	int illuminance_value;
> +	int light_color_temp;
>  } __packed;
>  
>  struct hpd_feature_report {
> diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
> index 697f2791ea9c..26e994e54ded 100644
> --- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
> +++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
> @@ -641,6 +641,13 @@ static const u8 als_report_descriptor[] = {
>  0x75, 32,		/* HID report size(32) */
>  0x95, 1,		/* HID report count (1) */
>  0X81, 0x02,		/* HID Input (Data_Arr_Abs) */
> +0x0A, 0xD2, 0x04,	/* HID usage sensor data light temperature */
> +0x17, 0x00, 0x00, 0x01, 0x80,	 /* HID logical Min_32 */
> +0x27, 0xFF, 0xFF, 0xFF, 0x7F,	 /* HID logical Max_32 */
> +0x55, 0x0,		/* HID unit exponent(0x0) */
> +0x75, 32,		/* HID report size(32) */
> +0x95, 1,		/* HID report count (1) */
> +0X81, 0x02,		/* HID Input (Data_Arr_Abs) */
>  0xC0			/* HID end collection */
>  };
>  
> -- 
> 2.25.1
> 

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 5/9] HID: amd_sfh: Add support for SFH1.1 light color temperature
  2023-09-19  8:10 ` [PATCH v2 5/9] HID: amd_sfh: Add support for SFH1.1 " Basavaraj Natikar
@ 2023-09-20 15:25   ` Jiri Kosina
  0 siblings, 0 replies; 27+ messages in thread
From: Jiri Kosina @ 2023-09-20 15:25 UTC (permalink / raw)
  To: Basavaraj Natikar
  Cc: benjamin.tissoires, jic23, lars, srinivas.pandruvada, linux-input,
	linux-iio

On Tue, 19 Sep 2023, Basavaraj Natikar wrote:

> In most cases, ambient color sensors also support light color temperature.
> As a result, add support of light color temperature for SFH1.1.
> 
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

Acked-by: Jiri Kosina <jkosina@suse.cz>

> ---
>  drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c      |  6 ++++++
>  drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 13 +++++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
> index 06bdcf072d10..f100aaafa167 100644
> --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
> +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
> @@ -188,6 +188,7 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
>  	struct sfh_mag_data mag_data;
>  	struct sfh_als_data als_data;
>  	struct hpd_status hpdstatus;
> +	struct sfh_base_info binfo;
>  	void __iomem *sensoraddr;
>  	u8 report_size = 0;
>  
> @@ -235,6 +236,11 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
>  		memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data));
>  		get_common_inputs(&als_input.common_property, report_id);
>  		als_input.illuminance_value = float_to_int(als_data.lux);
> +
> +		memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info));
> +		if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2)
> +			als_input.light_color_temp = als_data.light_color_temp;
> +
>  		report_size = sizeof(als_input);
>  		memcpy(input_report, &als_input, sizeof(als_input));
>  		break;
> diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
> index 9d31d5b510eb..6f6f5db150c3 100644
> --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
> +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
> @@ -88,6 +88,16 @@ struct sfh_sensor_list {
>  	};
>  };
>  
> +struct sfh_sensor_prop {
> +	union {
> +		u32 sprop;
> +		struct {
> +			u32 elist	: 16;
> +			u32 feat	: 16;
> +		} sf;
> +	};
> +};
> +
>  struct sfh_base_info {
>  	union {
>  		u32 sfh_base[24];
> @@ -95,6 +105,8 @@ struct sfh_base_info {
>  			struct sfh_platform_info plat_info;
>  			struct sfh_firmware_info  fw_info;
>  			struct sfh_sensor_list s_list;
> +			u32 rsvd;
> +			struct sfh_sensor_prop s_prop[16];
>  		} sbase;
>  	};
>  };
> @@ -134,6 +146,7 @@ struct sfh_mag_data {
>  struct sfh_als_data {
>  	struct sfh_common_data commondata;
>  	u32 lux;
> +	u32 light_color_temp;
>  };
>  
>  struct hpd_status {
> -- 
> 2.25.1
> 

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 8/9] HID: amd_sfh: Add light chromaticity support
  2023-09-19  8:10 ` [PATCH v2 8/9] HID: amd_sfh: " Basavaraj Natikar
@ 2023-09-20 15:25   ` Jiri Kosina
  0 siblings, 0 replies; 27+ messages in thread
From: Jiri Kosina @ 2023-09-20 15:25 UTC (permalink / raw)
  To: Basavaraj Natikar
  Cc: benjamin.tissoires, jic23, lars, srinivas.pandruvada, linux-input,
	linux-iio

On Tue, 19 Sep 2023, Basavaraj Natikar wrote:

> In most cases, ambient color sensors also support the x and y light
> colors, which represent the coordinates on the CIE 1931 chromaticity
> diagram. Thus, add light chromaticity x and y.
> 
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

Acked-by: Jiri Kosina <jkosina@suse.cz>

> ---
>  .../amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c  |  5 ++++-
>  .../amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h  |  2 ++
>  .../hid_descriptor/amd_sfh_hid_report_desc.h       | 14 ++++++++++++++
>  3 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
> index b7e732ec4806..ef1f9be8b893 100644
> --- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
> +++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c
> @@ -258,8 +258,11 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id,
>  			als_input.illuminance_value =
>  				(int)sensor_virt_addr[0] / AMD_SFH_FW_MULTIPLIER;
>  
> -		if (sensor_idx == ACS_IDX)
> +		if (sensor_idx == ACS_IDX) {
>  			als_input.light_color_temp = sensor_virt_addr[1];
> +			als_input.chromaticity_x_value = sensor_virt_addr[2];
> +			als_input.chromaticity_y_value = sensor_virt_addr[3];
> +		}
>  
>  		report_size = sizeof(als_input);
>  		memcpy(input_report, &als_input, sizeof(als_input));
> diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
> index a7fc50deca4d..882434b1501f 100644
> --- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
> +++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h
> @@ -100,6 +100,8 @@ struct als_input_report {
>  	/* values specific to this sensor */
>  	int illuminance_value;
>  	int light_color_temp;
> +	int chromaticity_x_value;
> +	int chromaticity_y_value;
>  } __packed;
>  
>  struct hpd_feature_report {
> diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
> index 26e994e54ded..67ec2d6a417d 100644
> --- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
> +++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h
> @@ -648,6 +648,20 @@ static const u8 als_report_descriptor[] = {
>  0x75, 32,		/* HID report size(32) */
>  0x95, 1,		/* HID report count (1) */
>  0X81, 0x02,		/* HID Input (Data_Arr_Abs) */
> +0x0A, 0xD4, 0x04,       /* HID usage sensor data light chromaticity_x */
> +0x17, 0x00, 0x00, 0x01, 0x80,	 /* HID logical Min_32 */
> +0x27, 0xFF, 0xFF, 0xFF, 0x7F,	 /* HID logical Max_32 */
> +0x55, 0x0,		/* HID unit exponent(0x0) */
> +0x75, 32,		/* HID report size(32) */
> +0x95, 1,		/* HID report count(1) */
> +0X81, 0x02,		/* HID Input (Data_Var_Abs) */
> +0x0A, 0xD5, 0x04,       /* HID usage sensor data light chromaticity_y */
> +0x17, 0x00, 0x00, 0x01, 0x80,	 /* HID logical Min_32 */
> +0x27, 0xFF, 0xFF, 0xFF, 0x7F,	 /* HID logical Max_32 */
> +0x55, 0x0,		/* HID unit exponent(0x0) */
> +0x75, 32,		/* HID report size(32) */
> +0x95, 1,		/* HID report count (1) */
> +0X81, 0x02,		/* HID Input (Data_Var_Abs) */
>  0xC0			/* HID end collection */
>  };
>  
> -- 
> 2.25.1
> 

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 9/9] HID: amd_sfh: Add light chromaticity for SFH1.1
  2023-09-19  8:10 ` [PATCH v2 9/9] HID: amd_sfh: Add light chromaticity for SFH1.1 Basavaraj Natikar
@ 2023-09-20 15:26   ` Jiri Kosina
  0 siblings, 0 replies; 27+ messages in thread
From: Jiri Kosina @ 2023-09-20 15:26 UTC (permalink / raw)
  To: Basavaraj Natikar
  Cc: benjamin.tissoires, jic23, lars, srinivas.pandruvada, linux-input,
	linux-iio

On Tue, 19 Sep 2023, Basavaraj Natikar wrote:

> In most cases, ambient color sensors also support the x and y light
> colors, which represent the coordinates on the CIE 1931 chromaticity
> diagram. Thus, add light chromaticity x and y for SFH1.1.
> 
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

Acked-by: Jiri Kosina <jkosina@suse.cz>

> ---
>  drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c      | 5 ++++-
>  drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 2 ++
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
> index f100aaafa167..8a037de08e92 100644
> --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
> +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c
> @@ -238,8 +238,11 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
>  		als_input.illuminance_value = float_to_int(als_data.lux);
>  
>  		memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info));
> -		if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2)
> +		if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2) {
>  			als_input.light_color_temp = als_data.light_color_temp;
> +			als_input.chromaticity_x_value = float_to_int(als_data.chromaticity_x);
> +			als_input.chromaticity_y_value = float_to_int(als_data.chromaticity_y);
> +		}
>  
>  		report_size = sizeof(als_input);
>  		memcpy(input_report, &als_input, sizeof(als_input));
> diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
> index 6f6f5db150c3..656c3e95ef8c 100644
> --- a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
> +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h
> @@ -147,6 +147,8 @@ struct sfh_als_data {
>  	struct sfh_common_data commondata;
>  	u32 lux;
>  	u32 light_color_temp;
> +	u32 chromaticity_x;
> +	u32 chromaticity_y;
>  };
>  
>  struct hpd_status {
> -- 
> 2.25.1
> 

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 1/9] iio: hid-sensor-als: Use channel index to support more hub attributes
  2023-09-19  8:10 ` [PATCH v2 1/9] iio: hid-sensor-als: Use channel index to support more hub attributes Basavaraj Natikar
@ 2023-09-20 16:59   ` srinivas pandruvada
  0 siblings, 0 replies; 27+ messages in thread
From: srinivas pandruvada @ 2023-09-20 16:59 UTC (permalink / raw)
  To: Basavaraj Natikar, jikos, benjamin.tissoires, jic23, lars,
	linux-input, linux-iio

On Tue, 2023-09-19 at 13:40 +0530, Basavaraj Natikar wrote:
> Sensor hub attributes can be extended to support more channels.
> Repeat
> the reading for the two existing channels and store them separately.
> It
> still operates in the same manner as before where there was just one
> entry. So in order to support more sensor hub attributes for ALS use
> channel index to get specific sensor hub attributes.
> 
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Acked-by: Srinivas Pandruvada<srinivas.pandruvada@linux.intel.com>

> ---
>  drivers/iio/light/hid-sensor-als.c | 38 ++++++++++++++++------------
> --
>  1 file changed, 20 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/iio/light/hid-sensor-als.c
> b/drivers/iio/light/hid-sensor-als.c
> index eb1aedad7edc..efb1f8862b28 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
> @@ -24,7 +24,7 @@ enum {
>  struct als_state {
>         struct hid_sensor_hub_callbacks callbacks;
>         struct hid_sensor_common common_attributes;
> -       struct hid_sensor_hub_attribute_info als_illum;
> +       struct hid_sensor_hub_attribute_info
> als[CHANNEL_SCAN_INDEX_MAX];
>         struct {
>                 u32 illum[CHANNEL_SCAN_INDEX_MAX];
>                 u64 timestamp __aligned(8);
> @@ -99,8 +99,8 @@ static int als_read_raw(struct iio_dev *indio_dev,
>                 switch (chan->scan_index) {
>                 case  CHANNEL_SCAN_INDEX_INTENSITY:
>                 case  CHANNEL_SCAN_INDEX_ILLUM:
> -                       report_id = als_state->als_illum.report_id;
> -                       min = als_state->als_illum.logical_minimum;
> +                       report_id = als_state->als[chan-
> >scan_index].report_id;
> +                       min = als_state->als[chan-
> >scan_index].logical_minimum;
>                         address = HID_USAGE_SENSOR_LIGHT_ILLUM;
>                         break;
>                 default:
> @@ -242,22 +242,24 @@ static int als_parse_report(struct
> platform_device *pdev,
>                                 struct als_state *st)
>  {
>         int ret;
> +       int i;
> +
> +       for (i = 0; i <= CHANNEL_SCAN_INDEX_ILLUM; ++i) {
> +               ret = sensor_hub_input_get_attribute_info(hsdev,
> +                                               HID_INPUT_REPORT,
> +                                               usage_id,
> +                                               HID_USAGE_SENSOR_LIGH
> T_ILLUM,
> +                                               &st->als[i]);
> +               if (ret < 0)
> +                       return ret;
> +               als_adjust_channel_bit_mask(channels, i, st-
> >als[i].size);
> +
> +               dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index,
> +                       st->als[i].report_id);
> +       }
>  
> -       ret = sensor_hub_input_get_attribute_info(hsdev,
> HID_INPUT_REPORT,
> -                       usage_id,
> -                       HID_USAGE_SENSOR_LIGHT_ILLUM,
> -                       &st->als_illum);
> -       if (ret < 0)
> -               return ret;
> -       als_adjust_channel_bit_mask(channels,
> CHANNEL_SCAN_INDEX_INTENSITY,
> -                                   st->als_illum.size);
> -       als_adjust_channel_bit_mask(channels,
> CHANNEL_SCAN_INDEX_ILLUM,
> -                                       st->als_illum.size);
> -
> -       dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index,
> -                       st->als_illum.report_id);
> -
> -       st->scale_precision = hid_sensor_format_scale(usage_id, &st-
> >als_illum,
> +       st->scale_precision = hid_sensor_format_scale(usage_id,
> +                               &st-
> >als[CHANNEL_SCAN_INDEX_INTENSITY],
>                                 &st->scale_pre_decml, &st-
> >scale_post_decml);
>  
>         return ret;


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 3/9] iio: hid-sensor-als: Add light color temperature support
  2023-09-19  8:10 ` [PATCH v2 3/9] iio: hid-sensor-als: Add light color temperature support Basavaraj Natikar
@ 2023-09-20 17:00   ` srinivas pandruvada
  0 siblings, 0 replies; 27+ messages in thread
From: srinivas pandruvada @ 2023-09-20 17:00 UTC (permalink / raw)
  To: Basavaraj Natikar, jikos, benjamin.tissoires, jic23, lars,
	linux-input, linux-iio

On Tue, 2023-09-19 at 13:40 +0530, Basavaraj Natikar wrote:
> In most cases, ambient color sensors also support light color
> temperature.
> As a result, add support of light color temperature.
> 
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Acked-by: Srinivas Pandruvada<srinivas.pandruvada@linux.intel.com>

> ---
>  drivers/iio/light/hid-sensor-als.c | 37
> ++++++++++++++++++++++++++++--
>  include/linux/hid-sensor-ids.h     |  1 +
>  2 files changed, 36 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/light/hid-sensor-als.c
> b/drivers/iio/light/hid-sensor-als.c
> index efb1f8862b28..16a3f1941c27 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
> @@ -14,8 +14,9 @@
>  #include "../common/hid-sensors/hid-sensor-trigger.h"
>  
>  enum {
> -       CHANNEL_SCAN_INDEX_INTENSITY = 0,
> -       CHANNEL_SCAN_INDEX_ILLUM = 1,
> +       CHANNEL_SCAN_INDEX_INTENSITY,
> +       CHANNEL_SCAN_INDEX_ILLUM,
> +       CHANNEL_SCAN_INDEX_COLOR_TEMP,
>         CHANNEL_SCAN_INDEX_MAX
>  };
>  
> @@ -65,6 +66,16 @@ static const struct iio_chan_spec als_channels[] =
> {
>                 BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
>                 .scan_index = CHANNEL_SCAN_INDEX_ILLUM,
>         },
> +       {
> +               .type = IIO_COLORTEMP,
> +               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> +               .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET)
> |
> +               BIT(IIO_CHAN_INFO_SCALE) |
> +               BIT(IIO_CHAN_INFO_SAMP_FREQ) |
> +               BIT(IIO_CHAN_INFO_HYSTERESIS) |
> +               BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
> +               .scan_index = CHANNEL_SCAN_INDEX_COLOR_TEMP,
> +       },
>         IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
>  };
>  
> @@ -103,6 +114,11 @@ static int als_read_raw(struct iio_dev
> *indio_dev,
>                         min = als_state->als[chan-
> >scan_index].logical_minimum;
>                         address = HID_USAGE_SENSOR_LIGHT_ILLUM;
>                         break;
> +               case  CHANNEL_SCAN_INDEX_COLOR_TEMP:
> +                       report_id = als_state->als[chan-
> >scan_index].report_id;
> +                       min = als_state->als[chan-
> >scan_index].logical_minimum;
> +                       address =
> HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE;
> +                       break;
>                 default:
>                         report_id = -1;
>                         break;
> @@ -223,6 +239,10 @@ static int als_capture_sample(struct
> hid_sensor_hub_device *hsdev,
>                 als_state->scan.illum[CHANNEL_SCAN_INDEX_ILLUM] =
> sample_data;
>                 ret = 0;
>                 break;
> +       case HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE:
> +               als_state->scan.illum[CHANNEL_SCAN_INDEX_COLOR_TEMP]
> = sample_data;
> +               ret = 0;
> +               break;
>         case HID_USAGE_SENSOR_TIME_TIMESTAMP:
>                 als_state->timestamp =
> hid_sensor_convert_timestamp(&als_state->common_attributes,
>                                                                    
> *(s64 *)raw_data);
> @@ -258,6 +278,19 @@ static int als_parse_report(struct
> platform_device *pdev,
>                         st->als[i].report_id);
>         }
>  
> +       ret = sensor_hub_input_get_attribute_info(hsdev,
> HID_INPUT_REPORT,
> +                               usage_id,
> +                               HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERAT
> URE,
> +                               &st-
> >als[CHANNEL_SCAN_INDEX_COLOR_TEMP]);
> +       if (ret < 0)
> +               return ret;
> +       als_adjust_channel_bit_mask(channels,
> CHANNEL_SCAN_INDEX_COLOR_TEMP,
> +                               st-
> >als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size);
> +
> +       dev_dbg(&pdev->dev, "als %x:%x\n",
> +               st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index,
> +               st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id);
> +
>         st->scale_precision = hid_sensor_format_scale(usage_id,
>                                 &st-
> >als[CHANNEL_SCAN_INDEX_INTENSITY],
>                                 &st->scale_pre_decml, &st-
> >scale_post_decml);
> diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-
> sensor-ids.h
> index 13b1e65fbdcc..8af4fb3e0254 100644
> --- a/include/linux/hid-sensor-ids.h
> +++ b/include/linux/hid-sensor-ids.h
> @@ -21,6 +21,7 @@
>  #define
> HID_USAGE_SENSOR_ALS                                   0x200041
>  #define
> HID_USAGE_SENSOR_DATA_LIGHT                            0x2004d0
>  #define
> HID_USAGE_SENSOR_LIGHT_ILLUM                           0x2004d1
> +#define
> HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE               0x2004d2
>  
>  /* PROX (200011) */
>  #define HID_USAGE_SENSOR_PROX                                  
> 0x200011


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 7/9] iio: hid-sensor-als: Add light chromaticity support
  2023-09-19  8:10 ` [PATCH v2 7/9] iio: hid-sensor-als: Add light chromaticity support Basavaraj Natikar
@ 2023-09-20 17:10   ` srinivas pandruvada
  0 siblings, 0 replies; 27+ messages in thread
From: srinivas pandruvada @ 2023-09-20 17:10 UTC (permalink / raw)
  To: Basavaraj Natikar, jikos, benjamin.tissoires, jic23, lars,
	linux-input, linux-iio

On Tue, 2023-09-19 at 13:40 +0530, Basavaraj Natikar wrote:
> In most cases, ambient color sensors also support the x and y light
> colors, which represent the coordinates on the CIE 1931 chromaticity
> diagram. Thus, add light chromaticity x and y.
> 
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Acked-by: Srinivas Pandruvada<srinivas.pandruvada@linux.intel.com>

> ---
>  drivers/iio/light/hid-sensor-als.c | 63
> ++++++++++++++++++++++++++++++
>  include/linux/hid-sensor-ids.h     |  3 ++
>  2 files changed, 66 insertions(+)
> 
> diff --git a/drivers/iio/light/hid-sensor-als.c
> b/drivers/iio/light/hid-sensor-als.c
> index 16a3f1941c27..c9d114ff080a 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
> @@ -17,6 +17,8 @@ enum {
>         CHANNEL_SCAN_INDEX_INTENSITY,
>         CHANNEL_SCAN_INDEX_ILLUM,
>         CHANNEL_SCAN_INDEX_COLOR_TEMP,
> +       CHANNEL_SCAN_INDEX_CHROMATICITY_X,
> +       CHANNEL_SCAN_INDEX_CHROMATICITY_Y,
>         CHANNEL_SCAN_INDEX_MAX
>  };
>  
> @@ -76,6 +78,30 @@ static const struct iio_chan_spec als_channels[] =
> {
>                 BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
>                 .scan_index = CHANNEL_SCAN_INDEX_COLOR_TEMP,
>         },
> +       {
> +               .type = IIO_CHROMATICITY,
> +               .modified = 1,
> +               .channel2 = IIO_MOD_X,
> +               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> +               .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET)
> |
> +               BIT(IIO_CHAN_INFO_SCALE) |
> +               BIT(IIO_CHAN_INFO_SAMP_FREQ) |
> +               BIT(IIO_CHAN_INFO_HYSTERESIS) |
> +               BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
> +               .scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X,
> +       },
> +       {
> +               .type = IIO_CHROMATICITY,
> +               .modified = 1,
> +               .channel2 = IIO_MOD_Y,
> +               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> +               .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET)
> |
> +               BIT(IIO_CHAN_INFO_SCALE) |
> +               BIT(IIO_CHAN_INFO_SAMP_FREQ) |
> +               BIT(IIO_CHAN_INFO_HYSTERESIS) |
> +               BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
> +               .scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_Y,
> +       },
>         IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
>  };
>  
> @@ -119,6 +145,16 @@ static int als_read_raw(struct iio_dev
> *indio_dev,
>                         min = als_state->als[chan-
> >scan_index].logical_minimum;
>                         address =
> HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE;
>                         break;
> +               case  CHANNEL_SCAN_INDEX_CHROMATICITY_X:
> +                       report_id = als_state->als[chan-
> >scan_index].report_id;
> +                       min = als_state->als[chan-
> >scan_index].logical_minimum;
> +                       address =
> HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X;
> +                       break;
> +               case  CHANNEL_SCAN_INDEX_CHROMATICITY_Y:
> +                       report_id = als_state->als[chan-
> >scan_index].report_id;
> +                       min = als_state->als[chan-
> >scan_index].logical_minimum;
> +                       address =
> HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y;
> +                       break;
>                 default:
>                         report_id = -1;
>                         break;
> @@ -243,6 +279,14 @@ static int als_capture_sample(struct
> hid_sensor_hub_device *hsdev,
>                 als_state->scan.illum[CHANNEL_SCAN_INDEX_COLOR_TEMP]
> = sample_data;
>                 ret = 0;
>                 break;
> +       case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X:
> +               als_state-
> >scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_X] = sample_data;
> +               ret = 0;
> +               break;
> +       case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y:
> +               als_state-
> >scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_Y] = sample_data;
> +               ret = 0;
> +               break;
>         case HID_USAGE_SENSOR_TIME_TIMESTAMP:
>                 als_state->timestamp =
> hid_sensor_convert_timestamp(&als_state->common_attributes,
>                                                                    
> *(s64 *)raw_data);
> @@ -291,6 +335,25 @@ static int als_parse_report(struct
> platform_device *pdev,
>                 st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index,
>                 st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id);
>  
> +       for (i = 0; i < 2; i++) {
> +               int next_scan_index =
> CHANNEL_SCAN_INDEX_CHROMATICITY_X + i;
> +
> +               ret = sensor_hub_input_get_attribute_info(hsdev,
> +                               HID_INPUT_REPORT, usage_id,
> +                               HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X
> + i,
> +                               &st->als[next_scan_index]);
> +               if (ret < 0)
> +                       return ret;
> +
> +               als_adjust_channel_bit_mask(channels,
> +                                       CHANNEL_SCAN_INDEX_CHROMATICI
> TY_X + i,
> +                                       st-
> >als[next_scan_index].size);
> +
> +               dev_dbg(&pdev->dev, "als %x:%x\n",
> +                       st->als[next_scan_index].index,
> +                       st->als[next_scan_index].report_id);
> +       }
> +
>         st->scale_precision = hid_sensor_format_scale(usage_id,
>                                 &st-
> >als[CHANNEL_SCAN_INDEX_INTENSITY],
>                                 &st->scale_pre_decml, &st-
> >scale_post_decml);
> diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-
> sensor-ids.h
> index 8af4fb3e0254..6730ee900ee1 100644
> --- a/include/linux/hid-sensor-ids.h
> +++ b/include/linux/hid-sensor-ids.h
> @@ -22,6 +22,9 @@
>  #define
> HID_USAGE_SENSOR_DATA_LIGHT                            0x2004d0
>  #define
> HID_USAGE_SENSOR_LIGHT_ILLUM                           0x2004d1
>  #define
> HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE               0x2004d2
> +#define
> HID_USAGE_SENSOR_LIGHT_CHROMATICITY                    0x2004d3
> +#define
> HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X                  0x2004d4
> +#define
> HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y                  0x2004d5
>  
>  /* PROX (200011) */
>  #define HID_USAGE_SENSOR_PROX                                  
> 0x200011


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 6/9] iio: Add channel type for chromaticity
  2023-09-19  8:10 ` [PATCH v2 6/9] iio: Add channel type for chromaticity Basavaraj Natikar
@ 2023-09-24 12:31   ` Jonathan Cameron
  0 siblings, 0 replies; 27+ messages in thread
From: Jonathan Cameron @ 2023-09-24 12:31 UTC (permalink / raw)
  To: Basavaraj Natikar
  Cc: jikos, benjamin.tissoires, lars, srinivas.pandruvada, linux-input,
	linux-iio

On Tue, 19 Sep 2023 13:40:51 +0530
Basavaraj Natikar <Basavaraj.Natikar@amd.com> wrote:

> In most cases, ambient color sensors also support the x and y light
> colors, which represent the coordinates on the CIE 1931 chromaticity
> diagram. Thus, add channel type for chromaticity.
> 
> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
One small thing I fixed up whilst applying.

Jonathan

> ---
>  Documentation/ABI/testing/sysfs-bus-iio | 8 ++++++++
>  drivers/iio/industrialio-core.c         | 1 +
>  include/uapi/linux/iio/types.h          | 1 +
>  tools/iio/iio_event_monitor.c           | 1 +
>  4 files changed, 11 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
> index 4cf7ed9ca57b..0c9389ad3709 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -2186,3 +2186,11 @@ Contact:	linux-iio@vger.kernel.org
>  Description:
>  		Represents light color temperature, which measures light color
>  		temperature in Kelvin.
> +
> +What:		/sys/bus/iio/devices/iio:deviceX/in_chromaticity_x_raw
> +What:		/sys/bus/iio/devices/iio:deviceX/in_chromaticity_y_raw
> +KernelVersion:	6.7
> +Contact:	linux-iio@vger.kernel.org
> +Description:
> +		The x and y light color coordinate on the CIE 1931 chromaticity
> +		diagram.
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index cba942cadf97..6dc4d2b296bb 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -91,6 +91,7 @@ static const char * const iio_chan_type_name_spec[] = {
>  	[IIO_PHASE] = "phase",
>  	[IIO_MASSCONCENTRATION] = "massconcentration",
>  	[IIO_COLORTEMP] = "colortemp",
> +	[IIO_CHROMATICITY] = "chromaticity",
>  };
>  
>  static const char * const iio_modifier_names[] = {
> diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
> index 08c20e540c13..4832c611c027 100644
> --- a/include/uapi/linux/iio/types.h
> +++ b/include/uapi/linux/iio/types.h
> @@ -48,6 +48,7 @@ enum iio_chan_type {
>  	IIO_PHASE,
>  	IIO_MASSCONCENTRATION,
>  	IIO_COLORTEMP,
> +	IIO_CHROMATICITY,
>  };
>  
>  enum iio_modifier {
> diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
> index a63741e43ddf..5edacc358c5d 100644
> --- a/tools/iio/iio_event_monitor.c
> +++ b/tools/iio/iio_event_monitor.c
> @@ -175,6 +175,7 @@ static bool event_is_known(struct iio_event_data *event)
>  	case IIO_PHASE:
>  	case IIO_MASSCONCENTRATION:
>  	case IIO_COLORTEMP:
> +	case IIO_CHROMATICITY:
This is missing updating the strings in the same file.
I only notice whilst dealing with a merge conflict where the colortemp one was
there and this wasn't.
>  		break;
>  	default:
>  		return false;


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 0/9] Support light color temperature and chromaticity
  2023-09-20 15:23   ` Basavaraj Natikar
@ 2023-09-24 12:42     ` Jonathan Cameron
  2023-09-24 14:20       ` Basavaraj Natikar
  0 siblings, 1 reply; 27+ messages in thread
From: Jonathan Cameron @ 2023-09-24 12:42 UTC (permalink / raw)
  To: Basavaraj Natikar
  Cc: Jiri Kosina, Basavaraj Natikar, benjamin.tissoires, lars,
	srinivas.pandruvada, linux-input, linux-iio

On Wed, 20 Sep 2023 20:53:33 +0530
Basavaraj Natikar <bnatikar@amd.com> wrote:

> On 9/20/2023 7:43 PM, Jiri Kosina wrote:
> > On Tue, 19 Sep 2023, Basavaraj Natikar wrote:
> >  
> >> This series adds support for light color temperature and chromaticity.
> >>
> >> v1->v2:
> >> *Rename the series.
> >> *Rename als_illum to als channel as it supports other channels.
> >> *Update patch description to include same reading for the two existing
> >>  channels to use channel index to support more hub attributes.
> >> *Keep line length under 80chars in hid-sensor-als.
> >> *Add new channel type IIO_COLORTEMP.
> >> *Update patch description and its subject to add channel type for 
> >>  chromaticity. 
> >>
> >> Basavaraj Natikar (9):
> >>   iio: hid-sensor-als: Use channel index to support more hub attributes
> >>   iio: Add channel type light color temperature
> >>   iio: hid-sensor-als: Add light color temperature support
> >>   HID: amd_sfh: Add support for light color temperature
> >>   HID: amd_sfh: Add support for SFH1.1 light color temperature
> >>   iio: Add channel type for chromaticity
> >>   iio: hid-sensor-als: Add light chromaticity support
> >>   HID: amd_sfh: Add light chromaticity support
> >>   HID: amd_sfh: Add light chromaticity for SFH1.1
> >>
> >>  Documentation/ABI/testing/sysfs-bus-iio       |  15 ++
> >>  .../hid_descriptor/amd_sfh_hid_desc.c         |   7 +
> >>  .../hid_descriptor/amd_sfh_hid_desc.h         |   3 +
> >>  .../hid_descriptor/amd_sfh_hid_report_desc.h  |  21 +++
> >>  drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c |   9 ++
> >>  .../amd-sfh-hid/sfh1_1/amd_sfh_interface.h    |  15 ++
> >>  drivers/iio/industrialio-core.c               |   2 +
> >>  drivers/iio/light/hid-sensor-als.c            | 130 +++++++++++++++---
> >>  include/linux/hid-sensor-ids.h                |   4 +
> >>  include/uapi/linux/iio/types.h                |   2 +
> >>  tools/iio/iio_event_monitor.c                 |   3 +
> >>  11 files changed, 195 insertions(+), 16 deletions(-)  
> > I believe this should go through Jonathan's tree as a whole, right?  
> 
> Yes, this should go through Jonathan's tree as a whole.
> If you don't have concerns, can you please ack HID amd_sfh changes?

I'll do an immutable branch in case this needs pulling into the hid tree
later in the cycle.

In short that means I'll create a branch with just this series on top of v6.6-rc1
and push that out as ib-iio-hid-sensors-v6.6-rc1.
I'll then merge that into the IIO tree before I do a pull request.
The advantage of this being that it can be pulled into other trees as necessary
and keep the same git IDs etc so that git can cleanly unwind the splitting and
merging of the history to cover the different paths.

However, note this will be messy as the merge into IIO isn't clean. I'll fix it
up but please take a quick look at the testing branch of iio.git on kernel.org
where the results of that merge will be.  Some other channel types were added
recently. So the fix was obvious.

So applied to the branch ib-iio-hid-sensors-6.6-rc1.  I'll merge that into the
IIO tree. That will get pushed out as testing for the build bots to see if they can
find anything we missed before I push this out as togreg which is what
linux-next picks up.

Note the IB branch might be rebased if any test issues show up.

Thanks,

Jonathan

> 
> Thanks,
> --
> Basavaraj
> 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 0/9] Support light color temperature and chromaticity
  2023-09-24 12:42     ` Jonathan Cameron
@ 2023-09-24 14:20       ` Basavaraj Natikar
  0 siblings, 0 replies; 27+ messages in thread
From: Basavaraj Natikar @ 2023-09-24 14:20 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Jiri Kosina, Basavaraj Natikar, benjamin.tissoires, lars,
	srinivas.pandruvada, linux-input, linux-iio


On 9/24/2023 6:12 PM, Jonathan Cameron wrote:
> On Wed, 20 Sep 2023 20:53:33 +0530
> Basavaraj Natikar <bnatikar@amd.com> wrote:
>
>> On 9/20/2023 7:43 PM, Jiri Kosina wrote:
>>> On Tue, 19 Sep 2023, Basavaraj Natikar wrote:
>>>  
>>>> This series adds support for light color temperature and chromaticity.
>>>>
>>>> v1->v2:
>>>> *Rename the series.
>>>> *Rename als_illum to als channel as it supports other channels.
>>>> *Update patch description to include same reading for the two existing
>>>>  channels to use channel index to support more hub attributes.
>>>> *Keep line length under 80chars in hid-sensor-als.
>>>> *Add new channel type IIO_COLORTEMP.
>>>> *Update patch description and its subject to add channel type for 
>>>>  chromaticity. 
>>>>
>>>> Basavaraj Natikar (9):
>>>>   iio: hid-sensor-als: Use channel index to support more hub attributes
>>>>   iio: Add channel type light color temperature
>>>>   iio: hid-sensor-als: Add light color temperature support
>>>>   HID: amd_sfh: Add support for light color temperature
>>>>   HID: amd_sfh: Add support for SFH1.1 light color temperature
>>>>   iio: Add channel type for chromaticity
>>>>   iio: hid-sensor-als: Add light chromaticity support
>>>>   HID: amd_sfh: Add light chromaticity support
>>>>   HID: amd_sfh: Add light chromaticity for SFH1.1
>>>>
>>>>  Documentation/ABI/testing/sysfs-bus-iio       |  15 ++
>>>>  .../hid_descriptor/amd_sfh_hid_desc.c         |   7 +
>>>>  .../hid_descriptor/amd_sfh_hid_desc.h         |   3 +
>>>>  .../hid_descriptor/amd_sfh_hid_report_desc.h  |  21 +++
>>>>  drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c |   9 ++
>>>>  .../amd-sfh-hid/sfh1_1/amd_sfh_interface.h    |  15 ++
>>>>  drivers/iio/industrialio-core.c               |   2 +
>>>>  drivers/iio/light/hid-sensor-als.c            | 130 +++++++++++++++---
>>>>  include/linux/hid-sensor-ids.h                |   4 +
>>>>  include/uapi/linux/iio/types.h                |   2 +
>>>>  tools/iio/iio_event_monitor.c                 |   3 +
>>>>  11 files changed, 195 insertions(+), 16 deletions(-)  
>>> I believe this should go through Jonathan's tree as a whole, right?  
>> Yes, this should go through Jonathan's tree as a whole.
>> If you don't have concerns, can you please ack HID amd_sfh changes?
> I'll do an immutable branch in case this needs pulling into the hid tree
> later in the cycle.
>
> In short that means I'll create a branch with just this series on top of v6.6-rc1
> and push that out as ib-iio-hid-sensors-v6.6-rc1.
> I'll then merge that into the IIO tree before I do a pull request.
> The advantage of this being that it can be pulled into other trees as necessary
> and keep the same git IDs etc so that git can cleanly unwind the splitting and
> merging of the history to cover the different paths.
>
> However, note this will be messy as the merge into IIO isn't clean. I'll fix it
> up but please take a quick look at the testing branch of iio.git on kernel.org
> where the results of that merge will be.  Some other channel types were added
> recently. So the fix was obvious.
>
> So applied to the branch ib-iio-hid-sensors-6.6-rc1.  I'll merge that into the
> IIO tree. That will get pushed out as testing for the build bots to see if they can
> find anything we missed before I push this out as togreg which is what
> linux-next picks up.
>
> Note the IB branch might be rebased if any test issues show up.

Sure I will check testing branch, Thank you Jonathan.

Thanks,
--
Basavaraj



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 0/9] Support light color temperature and chromaticity
  2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
                   ` (9 preceding siblings ...)
  2023-09-20 14:13 ` [PATCH v2 0/9] Support light color temperature and chromaticity Jiri Kosina
@ 2023-12-06 23:39 ` Thomas Weißschuh
  2023-12-10 11:07   ` Jonathan Cameron
  2023-12-23  8:14   ` Linux regression tracking #update (Thorsten Leemhuis)
  10 siblings, 2 replies; 27+ messages in thread
From: Thomas Weißschuh @ 2023-12-06 23:39 UTC (permalink / raw)
  To: Basavaraj Natikar
  Cc: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio, regressions

Hi everybody,

On 2023-09-19 13:40:45+0530, Basavaraj Natikar wrote:
> This series adds support for light color temperature and chromaticity.
> 
> v1->v2:
> *Rename the series.
> *Rename als_illum to als channel as it supports other channels.
> *Update patch description to include same reading for the two existing
>  channels to use channel index to support more hub attributes.
> *Keep line length under 80chars in hid-sensor-als.
> *Add new channel type IIO_COLORTEMP.
> *Update patch description and its subject to add channel type for 
>  chromaticity. 
> 
> Basavaraj Natikar (9):
>   iio: hid-sensor-als: Use channel index to support more hub attributes
>   iio: Add channel type light color temperature
>   iio: hid-sensor-als: Add light color temperature support
>   HID: amd_sfh: Add support for light color temperature
>   HID: amd_sfh: Add support for SFH1.1 light color temperature
>   iio: Add channel type for chromaticity
>   iio: hid-sensor-als: Add light chromaticity support
>   HID: amd_sfh: Add light chromaticity support
>   HID: amd_sfh: Add light chromaticity for SFH1.1

This series is breaking probing of hid-sensor-als on Framework 13 AMD
laptops [0].
The problem is that the patches require hid-sensors-als sensors to also
report chromaticity and color temparature which they don't.

When I remove the 'if (ret < 0) return ret;' checks in
als_parse_report() probing works and the illuminance/intensity channels
that show up behave as expected.
Unfortunately this still leaves behind a bunch of unusable channels.
A nice fix would be to have something like sysfs/hwmon .is_visible()
callback but that's not supported by IIO.

One aproach would be to detect the usable channels in als_parse_report()
and then adapt the indio_dev->channels based on that information.

[0] https://bugzilla.kernel.org/show_bug.cgi?id=218223

#regzbot introduced: 5f05285df691b1e82108eead7165feae238c95ef
#regzbot monitor: https://bugzilla.kernel.org/show_bug.cgi?id=218223

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 0/9] Support light color temperature and chromaticity
  2023-12-06 23:39 ` Thomas Weißschuh
@ 2023-12-10 11:07   ` Jonathan Cameron
  2023-12-15 10:04     ` Linux regression tracking (Thorsten Leemhuis)
  2023-12-23  8:14   ` Linux regression tracking #update (Thorsten Leemhuis)
  1 sibling, 1 reply; 27+ messages in thread
From: Jonathan Cameron @ 2023-12-10 11:07 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Basavaraj Natikar, jikos, benjamin.tissoires, lars,
	srinivas.pandruvada, linux-input, linux-iio, regressions

On Thu, 7 Dec 2023 00:39:28 +0100
Thomas Weißschuh <thomas@t-8ch.de> wrote:

> Hi everybody,
> 
> On 2023-09-19 13:40:45+0530, Basavaraj Natikar wrote:
> > This series adds support for light color temperature and chromaticity.
> > 
> > v1->v2:
> > *Rename the series.
> > *Rename als_illum to als channel as it supports other channels.
> > *Update patch description to include same reading for the two existing
> >  channels to use channel index to support more hub attributes.
> > *Keep line length under 80chars in hid-sensor-als.
> > *Add new channel type IIO_COLORTEMP.
> > *Update patch description and its subject to add channel type for 
> >  chromaticity. 
> > 
> > Basavaraj Natikar (9):
> >   iio: hid-sensor-als: Use channel index to support more hub attributes
> >   iio: Add channel type light color temperature
> >   iio: hid-sensor-als: Add light color temperature support
> >   HID: amd_sfh: Add support for light color temperature
> >   HID: amd_sfh: Add support for SFH1.1 light color temperature
> >   iio: Add channel type for chromaticity
> >   iio: hid-sensor-als: Add light chromaticity support
> >   HID: amd_sfh: Add light chromaticity support
> >   HID: amd_sfh: Add light chromaticity for SFH1.1  
> 
> This series is breaking probing of hid-sensor-als on Framework 13 AMD
> laptops [0].
> The problem is that the patches require hid-sensors-als sensors to also
> report chromaticity and color temparature which they don't.
Gah.  Missed that in review.  Sorry about that and thanks for digging into
this.
> 
> When I remove the 'if (ret < 0) return ret;' checks in
> als_parse_report() probing works and the illuminance/intensity channels
> that show up behave as expected.
> Unfortunately this still leaves behind a bunch of unusable channels.
> A nice fix would be to have something like sysfs/hwmon .is_visible()
> callback but that's not supported by IIO.

It's tricky to do because there is no simple association between
what is registered as channels and the resulting attribute.  We could probably
make it work, but not a simple thing to do.

> 
> One aproach would be to detect the usable channels in als_parse_report()
> and then adapt the indio_dev->channels based on that information.
> 
> [0] https://bugzilla.kernel.org/show_bug.cgi?id=218223

Agreed that adapting the channels is the way to go.
Easiest option probably to set the relevant masks to 0 if the chromacity and
temp channels aren't there + set their scan index values to -1.
That 'should' suppress any attributes being created.
Having a gap in scan indexes is common anyway so any userspace should cope
with the timestamp being after a gap.

Alternatives would be to rebuild the chan_spec array to not have the entries,
or pass in and fill in two copies of the array, picking the relevant one only
on discovering if the temp and chromacity channels are present.

Jonathan

> 
> #regzbot introduced: 5f05285df691b1e82108eead7165feae238c95ef
> #regzbot monitor: https://bugzilla.kernel.org/show_bug.cgi?id=218223
> 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 0/9] Support light color temperature and chromaticity
  2023-12-10 11:07   ` Jonathan Cameron
@ 2023-12-15 10:04     ` Linux regression tracking (Thorsten Leemhuis)
  2023-12-15 17:33       ` srinivas pandruvada
  0 siblings, 1 reply; 27+ messages in thread
From: Linux regression tracking (Thorsten Leemhuis) @ 2023-12-15 10:04 UTC (permalink / raw)
  To: Jonathan Cameron, Thomas Weißschuh
  Cc: Basavaraj Natikar, jikos, benjamin.tissoires, lars,
	srinivas.pandruvada, linux-input, linux-iio, regressions

Hi, Thorsten here, the Linux kernel's regression tracker. Top-posting
for once, to make this easily accessible to everyone.

Thomas, Jonathan, was any progress made to resolve below regression?

Side note: vormally I would not prod you at this time of the cycle, but
with the festive season coming up I thought it would be wise to ask a
bit earlier for a status update.

Ciao, Thorsten

On 10.12.23 12:07, Jonathan Cameron wrote:
> On Thu, 7 Dec 2023 00:39:28 +0100
> Thomas Weißschuh <thomas@t-8ch.de> wrote:
>> On 2023-09-19 13:40:45+0530, Basavaraj Natikar wrote:
>>> This series adds support for light color temperature and chromaticity.
>[...]
>>> Basavaraj Natikar (9):
>>>   iio: hid-sensor-als: Use channel index to support more hub attributes
>>>   iio: Add channel type light color temperature
>>>   iio: hid-sensor-als: Add light color temperature support
>>>   HID: amd_sfh: Add support for light color temperature
>>>   HID: amd_sfh: Add support for SFH1.1 light color temperature
>>>   iio: Add channel type for chromaticity
>>>   iio: hid-sensor-als: Add light chromaticity support
>>>   HID: amd_sfh: Add light chromaticity support
>>>   HID: amd_sfh: Add light chromaticity for SFH1.1  
>>
>> This series is breaking probing of hid-sensor-als on Framework 13 AMD
>> laptops [0].
>> The problem is that the patches require hid-sensors-als sensors to also
>> report chromaticity and color temparature which they don't.
> Gah.  Missed that in review.  Sorry about that and thanks for digging into
> this.
>>
>> When I remove the 'if (ret < 0) return ret;' checks in
>> als_parse_report() probing works and the illuminance/intensity channels
>> that show up behave as expected.
>> Unfortunately this still leaves behind a bunch of unusable channels.
>> A nice fix would be to have something like sysfs/hwmon .is_visible()
>> callback but that's not supported by IIO.
> 
> It's tricky to do because there is no simple association between
> what is registered as channels and the resulting attribute.  We could probably
> make it work, but not a simple thing to do.
> 
>>
>> One aproach would be to detect the usable channels in als_parse_report()
>> and then adapt the indio_dev->channels based on that information.
>>
>> [0] https://bugzilla.kernel.org/show_bug.cgi?id=218223
> 
> Agreed that adapting the channels is the way to go.
> Easiest option probably to set the relevant masks to 0 if the chromacity and
> temp channels aren't there + set their scan index values to -1.
> That 'should' suppress any attributes being created.
> Having a gap in scan indexes is common anyway so any userspace should cope
> with the timestamp being after a gap.
> 
> Alternatives would be to rebuild the chan_spec array to not have the entries,
> or pass in and fill in two copies of the array, picking the relevant one only
> on discovering if the temp and chromacity channels are present.
> 
> Jonathan
> 
>>
>> #regzbot introduced: 5f05285df691b1e82108eead7165feae238c95ef
>> #regzbot monitor: https://bugzilla.kernel.org/show_bug.cgi?id=218223
>>
> 
> 
> 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 0/9] Support light color temperature and chromaticity
  2023-12-15 10:04     ` Linux regression tracking (Thorsten Leemhuis)
@ 2023-12-15 17:33       ` srinivas pandruvada
  0 siblings, 0 replies; 27+ messages in thread
From: srinivas pandruvada @ 2023-12-15 17:33 UTC (permalink / raw)
  To: Linux regressions mailing list, Jonathan Cameron,
	Thomas Weißschuh
  Cc: Basavaraj Natikar, jikos, benjamin.tissoires, lars, linux-input,
	linux-iio

On Fri, 2023-12-15 at 11:04 +0100, Linux regression tracking (Thorsten
Leemhuis) wrote:
> Hi, Thorsten here, the Linux kernel's regression tracker. Top-posting
> for once, to make this easily accessible to everyone.
> 
> Thomas, Jonathan, was any progress made to resolve below regression?

A patch is posted
https://patchwork.kernel.org/project/linux-iio/patch/20231215160159.648963-1-srinivas.pandruvada@linux.intel.com/

Thanks,
Srinivas

> 
> Side note: vormally I would not prod you at this time of the cycle,
> but
> with the festive season coming up I thought it would be wise to ask a
> bit earlier for a status update.
> 
> Ciao, Thorsten
> 
> On 10.12.23 12:07, Jonathan Cameron wrote:
> > On Thu, 7 Dec 2023 00:39:28 +0100
> > Thomas Weißschuh <thomas@t-8ch.de> wrote:
> > > On 2023-09-19 13:40:45+0530, Basavaraj Natikar wrote:
> > > > This series adds support for light color temperature and
> > > > chromaticity.
> > [...]
> > > > Basavaraj Natikar (9):
> > > >   iio: hid-sensor-als: Use channel index to support more hub
> > > > attributes
> > > >   iio: Add channel type light color temperature
> > > >   iio: hid-sensor-als: Add light color temperature support
> > > >   HID: amd_sfh: Add support for light color temperature
> > > >   HID: amd_sfh: Add support for SFH1.1 light color temperature
> > > >   iio: Add channel type for chromaticity
> > > >   iio: hid-sensor-als: Add light chromaticity support
> > > >   HID: amd_sfh: Add light chromaticity support
> > > >   HID: amd_sfh: Add light chromaticity for SFH1.1  
> > > 
> > > This series is breaking probing of hid-sensor-als on Framework 13
> > > AMD
> > > laptops [0].
> > > The problem is that the patches require hid-sensors-als sensors
> > > to also
> > > report chromaticity and color temparature which they don't.
> > Gah.  Missed that in review.  Sorry about that and thanks for
> > digging into
> > this.
> > > 
> > > When I remove the 'if (ret < 0) return ret;' checks in
> > > als_parse_report() probing works and the illuminance/intensity
> > > channels
> > > that show up behave as expected.
> > > Unfortunately this still leaves behind a bunch of unusable
> > > channels.
> > > A nice fix would be to have something like sysfs/hwmon
> > > .is_visible()
> > > callback but that's not supported by IIO.
> > 
> > It's tricky to do because there is no simple association between
> > what is registered as channels and the resulting attribute.  We
> > could probably
> > make it work, but not a simple thing to do.
> > 
> > > 
> > > One aproach would be to detect the usable channels in
> > > als_parse_report()
> > > and then adapt the indio_dev->channels based on that information.
> > > 
> > > [0] https://bugzilla.kernel.org/show_bug.cgi?id=218223
> > 
> > Agreed that adapting the channels is the way to go.
> > Easiest option probably to set the relevant masks to 0 if the
> > chromacity and
> > temp channels aren't there + set their scan index values to -1.
> > That 'should' suppress any attributes being created.
> > Having a gap in scan indexes is common anyway so any userspace
> > should cope
> > with the timestamp being after a gap.
> > 
> > Alternatives would be to rebuild the chan_spec array to not have
> > the entries,
> > or pass in and fill in two copies of the array, picking the
> > relevant one only
> > on discovering if the temp and chromacity channels are present.
> > 
> > Jonathan
> > 
> > > 
> > > #regzbot introduced: 5f05285df691b1e82108eead7165feae238c95ef
> > > #regzbot monitor:
> > > https://bugzilla.kernel.org/show_bug.cgi?id=218223
> > > 
> > 
> > 
> > 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH v2 0/9] Support light color temperature and chromaticity
  2023-12-06 23:39 ` Thomas Weißschuh
  2023-12-10 11:07   ` Jonathan Cameron
@ 2023-12-23  8:14   ` Linux regression tracking #update (Thorsten Leemhuis)
  1 sibling, 0 replies; 27+ messages in thread
From: Linux regression tracking #update (Thorsten Leemhuis) @ 2023-12-23  8:14 UTC (permalink / raw)
  To: Thomas Weißschuh, Basavaraj Natikar
  Cc: jikos, benjamin.tissoires, jic23, lars, srinivas.pandruvada,
	linux-input, linux-iio, regressions

[TLDR: This mail in primarily relevant for Linux regression tracking. A
change or fix related to the regression discussed in this thread was
posted or applied, but it did not use a Closes: tag to point to the
report, as Linus and the documentation call for. Things happen, no
worries -- but now the regression tracking bot needs to be told manually
about the fix. See link in footer if these mails annoy you.]

On 07.12.23 00:39, Thomas Weißschuh wrote:
> On 2023-09-19 13:40:45+0530, Basavaraj Natikar wrote:
> [...]
> This series is breaking probing of hid-sensor-als on Framework 13 AMD
> laptops [0].
> [...]
> #regzbot introduced: 5f05285df691b1e82108eead7165feae238c95ef
> #regzbot monitor: https://bugzilla.kernel.org/show_bug.cgi?id=218223

#regzbot fix: d4005431673929
#regzbot ignore-activity

Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat)
--
Everything you wanna know about Linux kernel regression tracking:
https://linux-regtracking.leemhuis.info/about/#tldr
That page also explains what to do if mails like this annoy you.



^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2023-12-23  8:40 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-19  8:10 [PATCH v2 0/9] Support light color temperature and chromaticity Basavaraj Natikar
2023-09-19  8:10 ` [PATCH v2 1/9] iio: hid-sensor-als: Use channel index to support more hub attributes Basavaraj Natikar
2023-09-20 16:59   ` srinivas pandruvada
2023-09-19  8:10 ` [PATCH v2 2/9] iio: Add channel type light color temperature Basavaraj Natikar
2023-09-19  8:10 ` [PATCH v2 3/9] iio: hid-sensor-als: Add light color temperature support Basavaraj Natikar
2023-09-20 17:00   ` srinivas pandruvada
2023-09-19  8:10 ` [PATCH v2 4/9] HID: amd_sfh: Add support for light color temperature Basavaraj Natikar
2023-09-20 15:25   ` Jiri Kosina
2023-09-19  8:10 ` [PATCH v2 5/9] HID: amd_sfh: Add support for SFH1.1 " Basavaraj Natikar
2023-09-20 15:25   ` Jiri Kosina
2023-09-19  8:10 ` [PATCH v2 6/9] iio: Add channel type for chromaticity Basavaraj Natikar
2023-09-24 12:31   ` Jonathan Cameron
2023-09-19  8:10 ` [PATCH v2 7/9] iio: hid-sensor-als: Add light chromaticity support Basavaraj Natikar
2023-09-20 17:10   ` srinivas pandruvada
2023-09-19  8:10 ` [PATCH v2 8/9] HID: amd_sfh: " Basavaraj Natikar
2023-09-20 15:25   ` Jiri Kosina
2023-09-19  8:10 ` [PATCH v2 9/9] HID: amd_sfh: Add light chromaticity for SFH1.1 Basavaraj Natikar
2023-09-20 15:26   ` Jiri Kosina
2023-09-20 14:13 ` [PATCH v2 0/9] Support light color temperature and chromaticity Jiri Kosina
2023-09-20 15:23   ` Basavaraj Natikar
2023-09-24 12:42     ` Jonathan Cameron
2023-09-24 14:20       ` Basavaraj Natikar
2023-12-06 23:39 ` Thomas Weißschuh
2023-12-10 11:07   ` Jonathan Cameron
2023-12-15 10:04     ` Linux regression tracking (Thorsten Leemhuis)
2023-12-15 17:33       ` srinivas pandruvada
2023-12-23  8:14   ` Linux regression tracking #update (Thorsten Leemhuis)

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).