linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Cc: <jikos@kernel.org>, <benjamin.tissoires@redhat.com>,
	<lars@metafoo.de>, <srinivas.pandruvada@linux.intel.com>,
	<linux-input@vger.kernel.org>, <linux-iio@vger.kernel.org>
Subject: Re: [PATCH 2/8] iio: hid-sensor-als: Add light color temperature support
Date: Sun, 17 Sep 2023 12:00:54 +0100	[thread overview]
Message-ID: <20230917120054.04e040e4@jic23-huawei> (raw)
In-Reply-To: <20230915051703.1689578-3-Basavaraj.Natikar@amd.com>

On Fri, 15 Sep 2023 10:46:57 +0530
Basavaraj Natikar <Basavaraj.Natikar@amd.com> 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>
> ---
>  drivers/iio/light/hid-sensor-als.c | 33 ++++++++++++++++++++++++++++++
>  include/linux/hid-sensor-ids.h     |  1 +
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
> index 48879e233aec..220fb93fea6d 100644
> --- a/drivers/iio/light/hid-sensor-als.c
> +++ b/drivers/iio/light/hid-sensor-als.c
> @@ -16,6 +16,7 @@
>  enum {
>  	CHANNEL_SCAN_INDEX_INTENSITY = 0,
>  	CHANNEL_SCAN_INDEX_ILLUM = 1,

Either drop, the = 1 or keep consistency for TEMP. 
I don't think the = 1 is useful so I'd drop it.

> +	CHANNEL_SCAN_INDEX_COLOR_TEMP,
>  	CHANNEL_SCAN_INDEX_MAX
>  };
>  
> @@ -65,6 +66,18 @@ static const struct iio_chan_spec als_channels[] = {
>  		BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
>  		.scan_index = CHANNEL_SCAN_INDEX_ILLUM,
>  	},
> +	{
> +		.type = IIO_TEMP,

Using a temperature channel for color temp is a bit of a stretch,
Particularly as it's likely we will see light sensors with actual
air temperature sensors in them at somepoint even if we don't have
any already.

So this needs a new channel type
IIO_COLORTEMP or similar.

Units for this probably want to be kelvin unlike the mili decrees centigrade
used for IIO_TEMP.

> +		.modified = 1,
> +		.channel2 = IIO_MOD_TEMP_AMBIENT,

I don't really see the modifier as useful here. That exists for thermocouple
type systems where it is necessary to know ambient vs sample temperatures.


> +		.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 +116,11 @@ static int als_read_raw(struct iio_dev *indio_dev,
>  			min = als_state->als_illum[chan->scan_index].logical_minimum;
>  			address = HID_USAGE_SENSOR_LIGHT_ILLUM;
>  			break;
> +		case  CHANNEL_SCAN_INDEX_COLOR_TEMP:
> +			report_id = als_state->als_illum[chan->scan_index].report_id;
> +			min = als_state->als_illum[chan->scan_index].logical_minimum;
> +			address = HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE;
> +			break;
>  		default:
>  			report_id = -1;
>  			break;
> @@ -223,6 +241,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);
> @@ -256,6 +278,17 @@ static int als_parse_report(struct platform_device *pdev,
>  			st->als_illum[i].report_id);
>  	}
>  
> +	ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT, usage_id,
> +						  HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE,
> +						  &st->als_illum[CHANNEL_SCAN_INDEX_COLOR_TEMP]);
> +	if (ret < 0)
> +		return ret;
> +	als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_COLOR_TEMP,
> +				    st->als_illum[CHANNEL_SCAN_INDEX_COLOR_TEMP].size);
> +
> +	dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum[CHANNEL_SCAN_INDEX_COLOR_TEMP].index,
> +		st->als_illum[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id);
> +
>  	st->scale_precision = hid_sensor_format_scale(usage_id,
>  						      &st->als_illum[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


  reply	other threads:[~2023-09-17 11:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15  5:16 [PATCH 0/8] Multiple light sensor support Basavaraj Natikar
2023-09-15  5:16 ` [PATCH 1/8] iio: hid-sensor-als: Use channel index to support more hub attributes Basavaraj Natikar
2023-09-17 10:56   ` Jonathan Cameron
2023-09-15  5:16 ` [PATCH 2/8] iio: hid-sensor-als: Add light color temperature support Basavaraj Natikar
2023-09-17 11:00   ` Jonathan Cameron [this message]
2023-09-17 14:43     ` Basavaraj Natikar
2023-09-18 10:58       ` Jonathan Cameron
2023-09-15  5:16 ` [PATCH 3/8] HID: amd_sfh: Add support for light color temperature Basavaraj Natikar
2023-09-15  5:16 ` [PATCH 4/8] HID: amd_sfh: Add support for SFH1.1 " Basavaraj Natikar
2023-09-15  5:17 ` [PATCH 5/8] iio: Add channel for chromaticity Basavaraj Natikar
2023-09-17 11:04   ` Jonathan Cameron
2023-09-15  5:17 ` [PATCH 6/8] iio: hid-sensor-als: Add light chromaticity support Basavaraj Natikar
2023-09-15  5:17 ` [PATCH 7/8] HID: amd_sfh: " Basavaraj Natikar
2023-09-15  5:17 ` [PATCH 8/8] HID: amd_sfh: Add light chromaticity for SFH1.1 Basavaraj Natikar
2023-09-17 11:09 ` [PATCH 0/8] Multiple light sensor support Jonathan Cameron

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20230917120054.04e040e4@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

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

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