diff mbox series

[v2,9/9] HID: amd_sfh: Add light chromaticity for SFH1.1

Message ID 20230919081054.2050714-10-Basavaraj.Natikar@amd.com
State Accepted
Commit c6c97210e27237438689611980f8a7b87bcc79bf
Headers show
Series [v2,1/9] iio: hid-sensor-als: Use channel index to support more hub attributes | expand

Commit Message

Basavaraj Natikar Sept. 19, 2023, 8:10 a.m. UTC
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(-)

Comments

Jiri Kosina Sept. 20, 2023, 3:26 p.m. UTC | #1
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
>
diff mbox series

Patch

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 {