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
2224Description:2224Description:
2225 Number of conditions that must occur, during a running2225 Number of conditions that must occur, during a running
2226 period, before an event is generated.2226 period, before an event is generated.
2227
2228What: /sys/bus/iio/devices/iio:deviceX/in_colortemp_raw
2229KernelVersion: 6.7
2230Contact: linux-iio@vger.kernel.org
2231Description:
2232 Represents light color temperature, which measures light color
2233 temperature in Kelvin.
2234
2235What: /sys/bus/iio/devices/iio:deviceX/in_chromaticity_x_raw
2236What: /sys/bus/iio/devices/iio:deviceX/in_chromaticity_y_raw
2237KernelVersion: 6.7
2238Contact: linux-iio@vger.kernel.org
2239Description:
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
257 else257 else
258 als_input.illuminance_value =258 als_input.illuminance_value =
259 (int)sensor_virt_addr[0] / AMD_SFH_FW_MULTIPLIER;259 (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
260 report_size = sizeof(als_input);267 report_size = sizeof(als_input);
261 memcpy(input_report, &als_input, sizeof(als_input));268 memcpy(input_report, &als_input, sizeof(als_input));
262 break;269 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
99 struct common_input_property common_property;99 struct common_input_property common_property;
100 /* values specific to this sensor */100 /* values specific to this sensor */
101 int illuminance_value;101 int illuminance_value;
102 int light_color_temp;
103 int chromaticity_x_value;
104 int chromaticity_y_value;
102} __packed;105} __packed;
103 106
104struct hpd_feature_report {107struct 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
6410x75, 32, /* HID report size(32) */6410x75, 32, /* HID report size(32) */
6420x95, 1, /* HID report count (1) */6420x95, 1, /* HID report count (1) */
6430X81, 0x02, /* HID Input (Data_Arr_Abs) */6430X81, 0x02, /* HID Input (Data_Arr_Abs) */
6440x0A, 0xD2, 0x04, /* HID usage sensor data light temperature */
6450x17, 0x00, 0x00, 0x01, 0x80, /* HID logical Min_32 */
6460x27, 0xFF, 0xFF, 0xFF, 0x7F, /* HID logical Max_32 */
6470x55, 0x0, /* HID unit exponent(0x0) */
6480x75, 32, /* HID report size(32) */
6490x95, 1, /* HID report count (1) */
6500X81, 0x02, /* HID Input (Data_Arr_Abs) */
6510x0A, 0xD4, 0x04, /* HID usage sensor data light chromaticity_x */
6520x17, 0x00, 0x00, 0x01, 0x80, /* HID logical Min_32 */
6530x27, 0xFF, 0xFF, 0xFF, 0x7F, /* HID logical Max_32 */
6540x55, 0x0, /* HID unit exponent(0x0) */
6550x75, 32, /* HID report size(32) */
6560x95, 1, /* HID report count(1) */
6570X81, 0x02, /* HID Input (Data_Var_Abs) */
6580x0A, 0xD5, 0x04, /* HID usage sensor data light chromaticity_y */
6590x17, 0x00, 0x00, 0x01, 0x80, /* HID logical Min_32 */
6600x27, 0xFF, 0xFF, 0xFF, 0x7F, /* HID logical Max_32 */
6610x55, 0x0, /* HID unit exponent(0x0) */
6620x75, 32, /* HID report size(32) */
6630x95, 1, /* HID report count (1) */
6640X81, 0x02, /* HID Input (Data_Var_Abs) */
6440xC0 /* HID end collection */6650xC0 /* HID end collection */
645};666};
646 667
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
188 struct sfh_mag_data mag_data;188 struct sfh_mag_data mag_data;
189 struct sfh_als_data als_data;189 struct sfh_als_data als_data;
190 struct hpd_status hpdstatus;190 struct hpd_status hpdstatus;
191 struct sfh_base_info binfo;
191 void __iomem *sensoraddr;192 void __iomem *sensoraddr;
192 u8 report_size = 0;193 u8 report_size = 0;
193 194
@@ -235,6 +236,14 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, · 41 unmodified lines
235 memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data));236 memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data));
236 get_common_inputs(&als_input.common_property, report_id);237 get_common_inputs(&als_input.common_property, report_id);
237 als_input.illuminance_value = float_to_int(als_data.lux);238 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
238 report_size = sizeof(als_input);247 report_size = sizeof(als_input);
239 memcpy(input_report, &als_input, sizeof(als_input));248 memcpy(input_report, &als_input, sizeof(als_input));
240 break;249 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
88 };88 };
89};89};
90 90
91struct sfh_sensor_prop {
92 union {
93 u32 sprop;
94 struct {
95 u32 elist : 16;
96 u32 feat : 16;
97 } sf;
98 };
99};
100
91struct sfh_base_info {101struct sfh_base_info {
92 union {102 union {
93 u32 sfh_base[24];103 u32 sfh_base[24];
@@ -95,6 +105,8 @@ struct sfh_base_info { · 1 unmodified line
95 struct sfh_platform_info plat_info;105 struct sfh_platform_info plat_info;
96 struct sfh_firmware_info fw_info;106 struct sfh_firmware_info fw_info;
97 struct sfh_sensor_list s_list;107 struct sfh_sensor_list s_list;
108 u32 rsvd;
109 struct sfh_sensor_prop s_prop[16];
98 } sbase;110 } sbase;
99 };111 };
100};112};
@@ -134,6 +146,9 @@ struct sfh_mag_data { · 33 unmodified lines
134struct sfh_als_data {146struct sfh_als_data {
135 struct sfh_common_data commondata;147 struct sfh_common_data commondata;
136 u32 lux;148 u32 lux;
149 u32 light_color_temp;
150 u32 chromaticity_x;
151 u32 chromaticity_y;
137};152};
138 153
139struct hpd_status {154struct 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
92 [IIO_MASSCONCENTRATION] = "massconcentration",92 [IIO_MASSCONCENTRATION] = "massconcentration",
93 [IIO_DELTA_ANGL] = "deltaangl",93 [IIO_DELTA_ANGL] = "deltaangl",
94 [IIO_DELTA_VELOCITY] = "deltavelocity",94 [IIO_DELTA_VELOCITY] = "deltavelocity",
95 [IIO_COLORTEMP] = "colortemp",
96 [IIO_CHROMATICITY] = "chromaticity",
95};97};
96 98
97static const char * const iio_modifier_names[] = {99static const char * const iio_modifier_names[] = {
drivers/iio/light/hid-sensor-als.c+114−16
@@ -14,8 +14,11 @@ · 13 unmodified lines
14#include "../common/hid-sensors/hid-sensor-trigger.h"14#include "../common/hid-sensors/hid-sensor-trigger.h"
15 15
16enum {16enum {
17 CHANNEL_SCAN_INDEX_INTENSITY = 0,17 CHANNEL_SCAN_INDEX_INTENSITY,
18 CHANNEL_SCAN_INDEX_ILLUM = 1,18 CHANNEL_SCAN_INDEX_ILLUM,
19 CHANNEL_SCAN_INDEX_COLOR_TEMP,
20 CHANNEL_SCAN_INDEX_CHROMATICITY_X,
21 CHANNEL_SCAN_INDEX_CHROMATICITY_Y,
19 CHANNEL_SCAN_INDEX_MAX22 CHANNEL_SCAN_INDEX_MAX
20};23};
21 24
@@ -24,7 +27,7 @@ enum { · 2 unmodified lines
24struct als_state {27struct als_state {
25 struct hid_sensor_hub_callbacks callbacks;28 struct hid_sensor_hub_callbacks callbacks;
26 struct hid_sensor_common common_attributes;29 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];
28 struct {31 struct {
29 u32 illum[CHANNEL_SCAN_INDEX_MAX];32 u32 illum[CHANNEL_SCAN_INDEX_MAX];
30 u64 timestamp __aligned(8);33 u64 timestamp __aligned(8);
@@ -65,6 +68,40 @@ static const struct iio_chan_spec als_channels[] = { · 34 unmodified lines
65 BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),68 BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE),
66 .scan_index = CHANNEL_SCAN_INDEX_ILLUM,69 .scan_index = CHANNEL_SCAN_INDEX_ILLUM,
67 },70 },
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 },
68 IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)105 IIO_CHAN_SOFT_TIMESTAMP(CHANNEL_SCAN_INDEX_TIMESTAMP)
69};106};
70 107
@@ -99,10 +136,25 @@ static int als_read_raw(struct iio_dev *indio_dev, · 28 unmodified lines
99 switch (chan->scan_index) {136 switch (chan->scan_index) {
100 case CHANNEL_SCAN_INDEX_INTENSITY:137 case CHANNEL_SCAN_INDEX_INTENSITY:
101 case CHANNEL_SCAN_INDEX_ILLUM:138 case CHANNEL_SCAN_INDEX_ILLUM:
102 report_id = als_state->als_illum.report_id;139 report_id = als_state->als[chan->scan_index].report_id;
103 min = als_state->als_illum.logical_minimum;140 min = als_state->als[chan->scan_index].logical_minimum;
104 address = HID_USAGE_SENSOR_LIGHT_ILLUM;141 address = HID_USAGE_SENSOR_LIGHT_ILLUM;
105 break;142 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;
106 default:158 default:
107 report_id = -1;159 report_id = -1;
108 break;160 break;
@@ -223,6 +275,18 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev, · 114 unmodified lines
223 als_state->scan.illum[CHANNEL_SCAN_INDEX_ILLUM] = sample_data;275 als_state->scan.illum[CHANNEL_SCAN_INDEX_ILLUM] = sample_data;
224 ret = 0;276 ret = 0;
225 break;277 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;
226 case HID_USAGE_SENSOR_TIME_TIMESTAMP:290 case HID_USAGE_SENSOR_TIME_TIMESTAMP:
227 als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes,291 als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes,
228 *(s64 *)raw_data);292 *(s64 *)raw_data);
@@ -242,22 +306,56 @@ static int als_parse_report(struct platform_device *pdev, · 13 unmodified lines
242 struct als_state *st)306 struct als_state *st)
243{307{
244 int ret;308 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 }
245 324
246 ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT,325 ret = sensor_hub_input_get_attribute_info(hsdev, HID_INPUT_REPORT,
247 usage_id,326 usage_id,
248 HID_USAGE_SENSOR_LIGHT_ILLUM,327 HID_USAGE_SENSOR_LIGHT_COLOR_TEMPERATURE,
249 &st->als_illum);328 &st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP]);
250 if (ret < 0)329 if (ret < 0)
251 return ret;330 return ret;
252 als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_INTENSITY,331 als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_COLOR_TEMP,
253 st->als_illum.size);332 st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].size);
254 als_adjust_channel_bit_mask(channels, CHANNEL_SCAN_INDEX_ILLUM,333
255 st->als_illum.size);334 dev_dbg(&pdev->dev, "als %x:%x\n",
256 335 st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].index,
257 dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index,336 st->als[CHANNEL_SCAN_INDEX_COLOR_TEMP].report_id);
258 st->als_illum.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 }
259 356
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],
261 &st->scale_pre_decml, &st->scale_post_decml);359 &st->scale_pre_decml, &st->scale_post_decml);
262 360
263 return ret;361 return ret;
include/linux/hid-sensor-ids.h+4−0
@@ -21,6 +21,10 @@ · 20 unmodified lines
21#define HID_USAGE_SENSOR_ALS 0x20004121#define HID_USAGE_SENSOR_ALS 0x200041
22#define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d022#define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0
23#define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d123#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
24 28
25/* PROX (200011) */29/* PROX (200011) */
26#define HID_USAGE_SENSOR_PROX 0x20001130#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
49 IIO_MASSCONCENTRATION,49 IIO_MASSCONCENTRATION,
50 IIO_DELTA_ANGL,50 IIO_DELTA_ANGL,
51 IIO_DELTA_VELOCITY,51 IIO_DELTA_VELOCITY,
52 IIO_COLORTEMP,
53 IIO_CHROMATICITY,
52};54};
53 55
54enum iio_modifier {56enum 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
61 [IIO_MASSCONCENTRATION] = "massconcentration",61 [IIO_MASSCONCENTRATION] = "massconcentration",
62 [IIO_DELTA_ANGL] = "deltaangl",62 [IIO_DELTA_ANGL] = "deltaangl",
63 [IIO_DELTA_VELOCITY] = "deltavelocity",63 [IIO_DELTA_VELOCITY] = "deltavelocity",
64 [IIO_COLORTEMP] = "colortemp",
65 [IIO_CHROMATICITY] = "chromaticity",
64};66};
65 67
66static const char * const iio_ev_type_text[] = {68static const char * const iio_ev_type_text[] = {
@@ -177,6 +179,8 @@ static bool event_is_known(struct iio_event_data *event) · 110 unmodified lines
177 case IIO_MASSCONCENTRATION:179 case IIO_MASSCONCENTRATION:
178 case IIO_DELTA_ANGL:180 case IIO_DELTA_ANGL:
179 case IIO_DELTA_VELOCITY:181 case IIO_DELTA_VELOCITY:
182 case IIO_COLORTEMP:
183 case IIO_CHROMATICITY:
180 break;184 break;
181 default:185 default:
182 return false;186 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