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.
Unified · Split
| @@ -2224,3 +2224,18 @@ Contact: linux-iio@vger.kernel.org · 2223 unmodified lines | ||
| 2224 | 2224 | Description: |
| 2225 | 2225 | Number of conditions that must occur, during a running |
| 2226 | 2226 | 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. | |
| @@ -257,6 +257,13 @@ static u8 get_input_report(u8 current_index, int sensor_idx, int report_id, · 256 unmodified lines | ||
| 257 | 257 | else |
| 258 | 258 | als_input.illuminance_value = |
| 259 | 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 | 267 | report_size = sizeof(als_input); |
| 261 | 268 | memcpy(input_report, &als_input, sizeof(als_input)); |
| 262 | 269 | break; |
| @@ -99,6 +99,9 @@ struct als_input_report { · 98 unmodified lines | ||
| 99 | 99 | struct common_input_property common_property; |
| 100 | 100 | /* values specific to this sensor */ |
| 101 | 101 | int illuminance_value; |
| 102 | + int light_color_temp; | |
| 103 | + int chromaticity_x_value; | |
| 104 | + int chromaticity_y_value; | |
| 102 | 105 | } __packed; |
| 103 | 106 | |
| 104 | 107 | struct hpd_feature_report { |
| @@ -641,6 +641,27 @@ static const u8 als_report_descriptor[] = { · 640 unmodified lines | ||
| 641 | 641 | 0x75, 32, /* HID report size(32) */ |
| 642 | 642 | 0x95, 1, /* HID report count (1) */ |
| 643 | 643 | 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) */ | |
| 644 | 665 | 0xC0 /* HID end collection */ |
| 645 | 666 | }; |
| 646 | 667 | |
| @@ -188,6 +188,7 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, · 187 unmodified lines | ||
| 188 | 188 | struct sfh_mag_data mag_data; |
| 189 | 189 | struct sfh_als_data als_data; |
| 190 | 190 | struct hpd_status hpdstatus; |
| 191 | + struct sfh_base_info binfo; | |
| 191 | 192 | void __iomem *sensoraddr; |
| 192 | 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 | 236 | memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data)); |
| 236 | 237 | get_common_inputs(&als_input.common_property, report_id); |
| 237 | 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 | 247 | report_size = sizeof(als_input); |
| 239 | 248 | memcpy(input_report, &als_input, sizeof(als_input)); |
| 240 | 249 | break; |
| @@ -88,6 +88,16 @@ struct sfh_sensor_list { · 87 unmodified lines | ||
| 88 | 88 | }; |
| 89 | 89 | }; |
| 90 | 90 | |
| 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 | + | |
| 91 | 101 | struct sfh_base_info { |
| 92 | 102 | union { |
| 93 | 103 | u32 sfh_base[24]; |
| @@ -95,6 +105,8 @@ struct sfh_base_info { · 1 unmodified line | ||
| 95 | 105 | struct sfh_platform_info plat_info; |
| 96 | 106 | struct sfh_firmware_info fw_info; |
| 97 | 107 | struct sfh_sensor_list s_list; |
| 108 | + u32 rsvd; | |
| 109 | + struct sfh_sensor_prop s_prop[16]; | |
| 98 | 110 | } sbase; |
| 99 | 111 | }; |
| 100 | 112 | }; |
| @@ -134,6 +146,9 @@ struct sfh_mag_data { · 33 unmodified lines | ||
| 134 | 146 | struct sfh_als_data { |
| 135 | 147 | struct sfh_common_data commondata; |
| 136 | 148 | u32 lux; |
| 149 | + u32 light_color_temp; | |
| 150 | + u32 chromaticity_x; | |
| 151 | + u32 chromaticity_y; | |
| 137 | 152 | }; |
| 138 | 153 | |
| 139 | 154 | struct hpd_status { |
| @@ -92,6 +92,8 @@ static const char * const iio_chan_type_name_spec[] = { · 91 unmodified lines | ||
| 92 | 92 | [IIO_MASSCONCENTRATION] = "massconcentration", |
| 93 | 93 | [IIO_DELTA_ANGL] = "deltaangl", |
| 94 | 94 | [IIO_DELTA_VELOCITY] = "deltavelocity", |
| 95 | + [IIO_COLORTEMP] = "colortemp", | |
| 96 | + [IIO_CHROMATICITY] = "chromaticity", | |
| 95 | 97 | }; |
| 96 | 98 | |
| 97 | 99 | static const char * const iio_modifier_names[] = { |
| @@ -14,8 +14,11 @@ · 13 unmodified lines | ||
| 14 | 14 | #include "../common/hid-sensors/hid-sensor-trigger.h" |
| 15 | 15 | |
| 16 | 16 | 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, | |
| 19 | 22 | CHANNEL_SCAN_INDEX_MAX |
| 20 | 23 | }; |
| 21 | 24 | |
| @@ -24,7 +27,7 @@ enum { · 2 unmodified lines | ||
| 24 | 27 | struct als_state { |
| 25 | 28 | struct hid_sensor_hub_callbacks callbacks; |
| 26 | 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 | 31 | struct { |
| 29 | 32 | u32 illum[CHANNEL_SCAN_INDEX_MAX]; |
| 30 | 33 | u64 timestamp __aligned(8); |
| @@ -65,6 +68,40 @@ static const struct iio_chan_spec als_channels[] = { · 34 unmodified lines | ||
| 65 | 68 | BIT(IIO_CHAN_INFO_HYSTERESIS_RELATIVE), |
| 66 | 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 | 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 | 136 | switch (chan->scan_index) { |
| 100 | 137 | case CHANNEL_SCAN_INDEX_INTENSITY: |
| 101 | 138 | 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; | |
| 104 | 141 | address = HID_USAGE_SENSOR_LIGHT_ILLUM; |
| 105 | 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 | 158 | default: |
| 107 | 159 | report_id = -1; |
| 108 | 160 | break; |
| @@ -223,6 +275,18 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev, · 114 unmodified lines | ||
| 223 | 275 | als_state->scan.illum[CHANNEL_SCAN_INDEX_ILLUM] = sample_data; |
| 224 | 276 | ret = 0; |
| 225 | 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 | 290 | case HID_USAGE_SENSOR_TIME_TIMESTAMP: |
| 227 | 291 | als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes, |
| 228 | 292 | *(s64 *)raw_data); |
| @@ -242,22 +306,56 @@ static int als_parse_report(struct platform_device *pdev, · 13 unmodified lines | ||
| 242 | 306 | struct als_state *st) |
| 243 | 307 | { |
| 244 | 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 | 325 | 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]); | |
| 250 | 329 | if (ret < 0) |
| 251 | 330 | 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 | + } | |
| 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 | 359 | &st->scale_pre_decml, &st->scale_post_decml); |
| 262 | 360 | |
| 263 | 361 | return ret; |
| @@ -21,6 +21,10 @@ · 20 unmodified lines | ||
| 21 | 21 | #define HID_USAGE_SENSOR_ALS 0x200041 |
| 22 | 22 | #define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0 |
| 23 | 23 | #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 | 29 | /* PROX (200011) */ |
| 26 | 30 | #define HID_USAGE_SENSOR_PROX 0x200011 |
| @@ -49,6 +49,8 @@ enum iio_chan_type { · 48 unmodified lines | ||
| 49 | 49 | IIO_MASSCONCENTRATION, |
| 50 | 50 | IIO_DELTA_ANGL, |
| 51 | 51 | IIO_DELTA_VELOCITY, |
| 52 | + IIO_COLORTEMP, | |
| 53 | + IIO_CHROMATICITY, | |
| 52 | 54 | }; |
| 53 | 55 | |
| 54 | 56 | enum iio_modifier { |
| @@ -61,6 +61,8 @@ static const char * const iio_chan_type_name_spec[] = { · 60 unmodified lines | ||
| 61 | 61 | [IIO_MASSCONCENTRATION] = "massconcentration", |
| 62 | 62 | [IIO_DELTA_ANGL] = "deltaangl", |
| 63 | 63 | [IIO_DELTA_VELOCITY] = "deltavelocity", |
| 64 | + [IIO_COLORTEMP] = "colortemp", | |
| 65 | + [IIO_CHROMATICITY] = "chromaticity", | |
| 64 | 66 | }; |
| 65 | 67 | |
| 66 | 68 | 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 | ||
| 177 | 179 | case IIO_MASSCONCENTRATION: |
| 178 | 180 | case IIO_DELTA_ANGL: |
| 179 | 181 | case IIO_DELTA_VELOCITY: |
| 182 | + case IIO_COLORTEMP: | |
| 183 | + case IIO_CHROMATICITY: | |
| 180 | 184 | break; |
| 181 | 185 | default: |
| 182 | 186 | return false; |