History

Merge branch 'ib-iio-hid-sensors-v6.6-rc1' into togreg

The deta angle and deta velocity channels were added in parallel with color temperature and chromacity so this merge had to assign a consistent order. I put the color related ones second.

Jonathan Cameron committed 3 years ago

Commit 431dffc2 parents 57d3909 c6c972111 files · +196 −16Browse files

Unified · Split

11 files
  1. Documentation/ABI/testing/sysfs-bus-iio +15 −0
  2. drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c +7 −0
  3. drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h +3 −0
  4. drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h +21 −0
  5. drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c +9 −0
  6. drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h +15 −0
  7. drivers/iio/industrialio-core.c +2 −0
  8. drivers/iio/light/hid-sensor-als.c +114 −16
  9. include/linux/hid-sensor-ids.h +4 −0
  10. include/uapi/linux/iio/types.h +2 −0
  11. tools/iio/iio_event_monitor.c +4 −0
Documentation/ABI/testing/sysfs-bus-iio+15−0
@@ -2224,3 +2224,18 @@ Contact: linux-iio@vger.kernel.org · 2223 unmodified lines
22242224 Description:
22252225 Number of conditions that must occur, during a running
22262226 period, before an event is generated.
2227+
2228+What: /sys/bus/iio/devices/iio:deviceX/in_colortemp_raw
2229+KernelVersion: 6.7
2230+Contact: linux-iio@vger.kernel.org
2231+Description:
2232+ Represents light color temperature, which measures light color
2233+ temperature in Kelvin.
2234+
2235+What: /sys/bus/iio/devices/iio:deviceX/in_chromaticity_x_raw
2236+What: /sys/bus/iio/devices/iio:deviceX/in_chromaticity_y_raw
2237+KernelVersion: 6.7
2238+Contact: linux-iio@vger.kernel.org
2239+Description:
2240+ The x and y light color coordinate on the CIE 1931 chromaticity
2241+ diagram.
drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c+7−0
@@ -257,6 +257,13 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id, · 256 unmodified lines
257257 else
258258 als_input.illuminance_value =
259259 (int)sensor_virt_addr[0] / AMD_SFH_FW_MULTIPLIER;
260+
261+ if (sensor_idx == ACS_IDX) {
262+ als_input.light_color_temp = sensor_virt_addr[1];
263+ als_input.chromaticity_x_value = sensor_virt_addr[2];
264+ als_input.chromaticity_y_value = sensor_virt_addr[3];
265+ }
266+
260267 report_size = sizeof(als_input);
261268 memcpy(input_report, &als_input, sizeof(als_input));
262269 break;
drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h+3−0
@@ -99,6 +99,9 @@ struct als_input_report { · 98 unmodified lines
9999 struct common_input_property common_property;
100100 /* values specific to this sensor */
101101 int illuminance_value;
102+ int light_color_temp;
103+ int chromaticity_x_value;
104+ int chromaticity_y_value;
102105 } __packed;
103106
104107 struct hpd_feature_report {
drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_report_desc.h+21−0
@@ -641,6 +641,27 @@ static const u8 als_report_descriptor[] = { · 640 unmodified lines
641641 0x75, 32, /* HID report size(32) */
642642 0x95, 1, /* HID report count (1) */
643643 0X81, 0x02, /* HID Input (Data_Arr_Abs) */
644+0x0A, 0xD2, 0x04, /* HID usage sensor data light temperature */
645+0x17, 0x00, 0x00, 0x01, 0x80, /* HID logical Min_32 */
646+0x27, 0xFF, 0xFF, 0xFF, 0x7F, /* HID logical Max_32 */
647+0x55, 0x0, /* HID unit exponent(0x0) */
648+0x75, 32, /* HID report size(32) */
649+0x95, 1, /* HID report count (1) */
650+0X81, 0x02, /* HID Input (Data_Arr_Abs) */
651+0x0A, 0xD4, 0x04, /* HID usage sensor data light chromaticity_x */
652+0x17, 0x00, 0x00, 0x01, 0x80, /* HID logical Min_32 */
653+0x27, 0xFF, 0xFF, 0xFF, 0x7F, /* HID logical Max_32 */
654+0x55, 0x0, /* HID unit exponent(0x0) */
655+0x75, 32, /* HID report size(32) */
656+0x95, 1, /* HID report count(1) */
657+0X81, 0x02, /* HID Input (Data_Var_Abs) */
658+0x0A, 0xD5, 0x04, /* HID usage sensor data light chromaticity_y */
659+0x17, 0x00, 0x00, 0x01, 0x80, /* HID logical Min_32 */
660+0x27, 0xFF, 0xFF, 0xFF, 0x7F, /* HID logical Max_32 */
661+0x55, 0x0, /* HID unit exponent(0x0) */
662+0x75, 32, /* HID report size(32) */
663+0x95, 1, /* HID report count (1) */
664+0X81, 0x02, /* HID Input (Data_Var_Abs) */
644665 0xC0 /* HID end collection */
645666 };
646667
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c+9−0
@@ -188,6 +188,7 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, · 187 unmodified lines
188188 struct sfh_mag_data mag_data;
189189 struct sfh_als_data als_data;
190190 struct hpd_status hpdstatus;
191+ struct sfh_base_info binfo;
191192 void __iomem *sensoraddr;
192193 u8 report_size = 0;
193194
@@ -235,6 +236,14 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, · 41 unmodified lines
235236 memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data));
236237 get_common_inputs(&als_input.common_property, report_id);
237238 als_input.illuminance_value = float_to_int(als_data.lux);
239+
240+ memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info));
241+ if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2) {
242+ als_input.light_color_temp = als_data.light_color_temp;
243+ als_input.chromaticity_x_value = float_to_int(als_data.chromaticity_x);
244+ als_input.chromaticity_y_value = float_to_int(als_data.chromaticity_y);
245+ }
246+
238247 report_size = sizeof(als_input);
239248 memcpy(input_report, &als_input, sizeof(als_input));
240249 break;
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h+15−0
@@ -88,6 +88,16 @@ struct sfh_sensor_list { · 87 unmodified lines
8888 };
8989 };
9090
91+struct sfh_sensor_prop {
92+ union {
93+ u32 sprop;
94+ struct {
95+ u32 elist : 16;
96+ u32 feat : 16;
97+ } sf;
98+ };
99+};
100+
91101 struct sfh_base_info {
92102 union {
93103 u32 sfh_base[24];
@@ -95,6 +105,8 @@ struct sfh_base_info { · 1 unmodified line
95105 struct sfh_platform_info plat_info;
96106 struct sfh_firmware_info fw_info;
97107 struct sfh_sensor_list s_list;
108+ u32 rsvd;
109+ struct sfh_sensor_prop s_prop[16];
98110 } sbase;
99111 };
100112 };
@@ -134,6 +146,9 @@ struct sfh_mag_data { · 33 unmodified lines
134146 struct sfh_als_data {
135147 struct sfh_common_data commondata;
136148 u32 lux;
149+ u32 light_color_temp;
150+ u32 chromaticity_x;
151+ u32 chromaticity_y;
137152 };
138153
139154 struct hpd_status {
drivers/iio/industrialio-core.c+2−0
@@ -92,6 +92,8 @@ static const char * const iio_chan_type_name_spec[] = { · 91 unmodified lines
9292 [IIO_MASSCONCENTRATION] = "massconcentration",
9393 [IIO_DELTA_ANGL] = "deltaangl",
9494 [IIO_DELTA_VELOCITY] = "deltavelocity",
95+ [IIO_COLORTEMP] = "colortemp",
96+ [IIO_CHROMATICITY] = "chromaticity",
9597 };
9698
9799 static const char * const iio_modifier_names[] = {
drivers/iio/light/hid-sensor-als.c+114−16
@@ -14,8 +14,11 @@ · 13 unmodified lines
1414 #include "../common/hid-sensors/hid-sensor-trigger.h"
1515
1616 enum {
17− CHANNEL_SCAN_INDEX_INTENSITY = 0,
18− CHANNEL_SCAN_INDEX_ILLUM = 1,
17+ CHANNEL_SCAN_INDEX_INTENSITY,
18+ CHANNEL_SCAN_INDEX_ILLUM,
19+ CHANNEL_SCAN_INDEX_COLOR_TEMP,
20+ CHANNEL_SCAN_INDEX_CHROMATICITY_X,
21+ CHANNEL_SCAN_INDEX_CHROMATICITY_Y,
1922 CHANNEL_SCAN_INDEX_MAX
2023 };
2124
@@ -24,7 +27,7 @@ enum { · 2 unmodified lines
2427 struct als_state {
2528 struct hid_sensor_hub_callbacks callbacks;
2629 struct hid_sensor_common common_attributes;
27− struct hid_sensor_hub_attribute_info als_illum;
30+ struct hid_sensor_hub_attribute_info als[CHANNEL_SCAN_INDEX_MAX];
2831 struct {
2932 u32 illum[CHANNEL_SCAN_INDEX_MAX];
3033 u64 timestamp __aligned(8);
@@ -65,6 +68,40 @@ static const struct iio_chan_spec als_channels[] = { · 34 unmodified lines
6568 BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
6669 .scan_index = CHANNEL_SCAN_INDEX_ILLUM,
6770 },
71+ {
72+ .type = IIO_COLORTEMP,
73+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
74+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
75+ BIT(IIO_CHAN_INFO_SCALE) |
76+ BIT(IIO_CHAN_INFO_SAMP_FREQ) |
77+ BIT(IIO_CHAN_INFO_HYSTERESIS) |
78+ BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
79+ .scan_index = CHANNEL_SCAN_INDEX_COLOR_TEMP,
80+ },
81+ {
82+ .type = IIO_CHROMATICITY,
83+ .modified = 1,
84+ .channel2 = IIO_MOD_X,
85+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
86+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
87+ BIT(IIO_CHAN_INFO_SCALE) |
88+ BIT(IIO_CHAN_INFO_SAMP_FREQ) |
89+ BIT(IIO_CHAN_INFO_HYSTERESIS) |
90+ BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
91+ .scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X,
92+ },
93+ {
94+ .type = IIO_CHROMATICITY,
95+ .modified = 1,
96+ .channel2 = IIO_MOD_Y,
97+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
98+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
99+ BIT(IIO_CHAN_INFO_SCALE) |
100+ BIT(IIO_CHAN_INFO_SAMP_FREQ) |
101+ BIT(IIO_CHAN_INFO_HYSTERESIS) |
102+ BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
103+ .scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_Y,
104+ },
68105 IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
69106 };
70107
@@ -99,10 +136,25 @@ static int als_read_raw(struct iio_dev *indio_dev, · 28 unmodified lines
99136 switch (chan->scan_index) {
100137 case CHANNEL_SCAN_INDEX_INTENSITY:
101138 case CHANNEL_SCAN_INDEX_ILLUM:
102− report_id = als_state->als_illum.report_id;
103− min = als_state->als_illum.logical_minimum;
139+ report_id = als_state->als[chan->scan_index].report_id;
140+ min = als_state->als[chan->scan_index].logical_minimum;
104141 address = HID_USAGE_SENSOR_LIGHT_ILLUM;
105142 break;
143+ case CHANNEL_SCAN_INDEX_COLOR_TEMP:
144+ report_id = als_state->als[chan->scan_index].report_id;
145+ min = als_state->als[chan->scan_index].logical_minimum;
146+ address = HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE;
147+ break;
148+ case CHANNEL_SCAN_INDEX_CHROMATICITY_X:
149+ report_id = als_state->als[chan->scan_index].report_id;
150+ min = als_state->als[chan->scan_index].logical_minimum;
151+ address = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X;
152+ break;
153+ case CHANNEL_SCAN_INDEX_CHROMATICITY_Y:
154+ report_id = als_state->als[chan->scan_index].report_id;
155+ min = als_state->als[chan->scan_index].logical_minimum;
156+ address = HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y;
157+ break;
106158 default:
107159 report_id = -1;
108160 break;
@@ -223,6 +275,18 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev, · 114 unmodified lines
223275 als_state->scan.illum[CHANNEL_SCAN_INDEX_ILLUM] = sample_data;
224276 ret = 0;
225277 break;
278+ case HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE:
279+ als_state->scan.illum[CHANNEL_SCAN_INDEX_COLOR_TEMP] = sample_data;
280+ ret = 0;
281+ break;
282+ case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X:
283+ als_state->scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_X] = sample_data;
284+ ret = 0;
285+ break;
286+ case HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y:
287+ als_state->scan.illum[CHANNEL_SCAN_INDEX_CHROMATICITY_Y] = sample_data;
288+ ret = 0;
289+ break;
226290 case HID_USAGE_SENSOR_TIME_TIMESTAMP:
227291 als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes,
228292 *(s64 *)raw_data);
@@ -242,22 +306,56 @@ static int als_parse_report(struct platform_device *pdev, · 13 unmodified lines
242306 struct als_state *st)
243307 {
244308 int ret;
309+ int i;
310+
311+ for (i = 0; i <= CHANNEL_SCAN_INDEX_ILLUM; ++i) {
312+ ret = sensor_hub_input_get_attribute_info(hsdev,
313+ HID_INPUT_REPORT,
314+ usage_id,
315+ HID_USAGE_SENSOR_LIGHT_ILLUM,
316+ &st->als[i]);
317+ if (ret < 0)
318+ return ret;
319+ als_adjust_channel_bit_mask(channels, i, st->als[i].size);
320+
321+ dev_dbg(&pdev->dev, "als %x:%x\n", st->als[i].index,
322+ st->als[i].report_id);
323+ }
245324
246325 ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT,
247− usage_id,
248− HID_USAGE_SENSOR_LIGHT_ILLUM,
249− &st->als_illum);
326+ usage_id,
327+ HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE,
328+ &st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP]);
250329 if (ret < 0)
251330 return ret;
252− als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_INTENSITY,
253− st->als_illum.size);
254− als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_ILLUM,
255− st->als_illum.size);
256−
257− dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index,
258− st->als_illum.report_id);
331+ als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_COLOR_TEMP,
332+ st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size);
333+
334+ dev_dbg(&pdev->dev, "als %x:%x\n",
335+ st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index,
336+ st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id);
337+
338+ for (i = 0; i < 2; i++) {
339+ int next_scan_index = CHANNEL_SCAN_INDEX_CHROMATICITY_X + i;
340+
341+ ret = sensor_hub_input_get_attribute_info(hsdev,
342+ HID_INPUT_REPORT, usage_id,
343+ HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X + i,
344+ &st->als[next_scan_index]);
345+ if (ret < 0)
346+ return ret;
347+
348+ als_adjust_channel_bit_mask(channels,
349+ CHANNEL_SCAN_INDEX_CHROMATICITY_X + i,
350+ st->als[next_scan_index].size);
351+
352+ dev_dbg(&pdev->dev, "als %x:%x\n",
353+ st->als[next_scan_index].index,
354+ st->als[next_scan_index].report_id);
355+ }
259356
260− st->scale_precision = hid_sensor_format_scale(usage_id, &st->als_illum,
357+ st->scale_precision = hid_sensor_format_scale(usage_id,
358+ &st->als[CHANNEL_SCAN_INDEX_INTENSITY],
261359 &st->scale_pre_decml, &st->scale_post_decml);
262360
263361 return ret;
include/linux/hid-sensor-ids.h+4−0
@@ -21,6 +21,10 @@ · 20 unmodified lines
2121 #define HID_USAGE_SENSOR_ALS 0x200041
2222 #define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0
2323 #define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1
24+#define HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE 0x2004d2
25+#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY 0x2004d3
26+#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY_X 0x2004d4
27+#define HID_USAGE_SENSOR_LIGHT_CHROMATICITY_Y 0x2004d5
2428
2529 /* PROX (200011) */
2630 #define HID_USAGE_SENSOR_PROX 0x200011
include/uapi/linux/iio/types.h+2−0
@@ -49,6 +49,8 @@ enum iio_chan_type { · 48 unmodified lines
4949 IIO_MASSCONCENTRATION,
5050 IIO_DELTA_ANGL,
5151 IIO_DELTA_VELOCITY,
52+ IIO_COLORTEMP,
53+ IIO_CHROMATICITY,
5254 };
5355
5456 enum iio_modifier {
tools/iio/iio_event_monitor.c+4−0
@@ -61,6 +61,8 @@ static const char * const iio_chan_type_name_spec[] = { · 60 unmodified lines
6161 [IIO_MASSCONCENTRATION] = "massconcentration",
6262 [IIO_DELTA_ANGL] = "deltaangl",
6363 [IIO_DELTA_VELOCITY] = "deltavelocity",
64+ [IIO_COLORTEMP] = "colortemp",
65+ [IIO_CHROMATICITY] = "chromaticity",
6466 };
6567
6668 static const char * const iio_ev_type_text[] = {
@@ -177,6 +179,8 @@ static bool event_is_known(struct iio_event_data *event) · 110 unmodified lines
177179 case IIO_MASSCONCENTRATION:
178180 case IIO_DELTA_ANGL:
179181 case IIO_DELTA_VELOCITY:
182+ case IIO_COLORTEMP:
183+ case IIO_CHROMATICITY:
180184 break;
181185 default:
182186 return false;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t