Lines Matching refs:iqs621_als
53 static int iqs621_als_init(struct iqs621_als_private *iqs621_als) in iqs621_als_init() argument
55 struct iqs62x_core *iqs62x = iqs621_als->iqs62x; in iqs621_als_init()
59 switch (iqs621_als->ir_flags_mask) { in iqs621_als_init()
62 iqs621_als->thresh_prox); in iqs621_als_init()
67 iqs621_als->thresh_prox); in iqs621_als_init()
72 iqs621_als->thresh_light); in iqs621_als_init()
77 iqs621_als->thresh_dark); in iqs621_als_init()
83 if (iqs621_als->light_en || iqs621_als->range_en) in iqs621_als_init()
86 if (iqs621_als->prox_en) in iqs621_als_init()
97 struct iqs621_als_private *iqs621_als; in iqs621_als_notifier() local
105 iqs621_als = container_of(notifier, struct iqs621_als_private, in iqs621_als_notifier()
107 indio_dev = iqs621_als->indio_dev; in iqs621_als_notifier()
110 mutex_lock(&iqs621_als->lock); in iqs621_als_notifier()
113 ret = iqs621_als_init(iqs621_als); in iqs621_als_notifier()
125 if (!iqs621_als->light_en && !iqs621_als->range_en && in iqs621_als_notifier()
126 !iqs621_als->prox_en) { in iqs621_als_notifier()
133 light_old = iqs621_als->als_flags & IQS621_ALS_FLAGS_LIGHT; in iqs621_als_notifier()
135 if (iqs621_als->light_en && light_new && !light_old) in iqs621_als_notifier()
141 else if (iqs621_als->light_en && !light_new && light_old) in iqs621_als_notifier()
150 range_old = iqs621_als->als_flags & IQS621_ALS_FLAGS_RANGE; in iqs621_als_notifier()
152 if (iqs621_als->range_en && (range_new > range_old)) in iqs621_als_notifier()
158 else if (iqs621_als->range_en && (range_new < range_old)) in iqs621_als_notifier()
166 prox_new = event_data->ir_flags & iqs621_als->ir_flags_mask; in iqs621_als_notifier()
167 prox_old = iqs621_als->ir_flags & iqs621_als->ir_flags_mask; in iqs621_als_notifier()
169 if (iqs621_als->prox_en && prox_new && !prox_old) in iqs621_als_notifier()
175 else if (iqs621_als->prox_en && !prox_new && prox_old) in iqs621_als_notifier()
182 iqs621_als->als_flags = event_data->als_flags; in iqs621_als_notifier()
183 iqs621_als->ir_flags = event_data->ir_flags; in iqs621_als_notifier()
187 mutex_unlock(&iqs621_als->lock); in iqs621_als_notifier()
194 struct iqs621_als_private *iqs621_als = context; in iqs621_als_notifier_unregister() local
195 struct iio_dev *indio_dev = iqs621_als->indio_dev; in iqs621_als_notifier_unregister()
198 ret = blocking_notifier_chain_unregister(&iqs621_als->iqs62x->nh, in iqs621_als_notifier_unregister()
199 &iqs621_als->notifier); in iqs621_als_notifier_unregister()
209 struct iqs621_als_private *iqs621_als = iio_priv(indio_dev); in iqs621_als_read_raw() local
210 struct iqs62x_core *iqs62x = iqs621_als->iqs62x; in iqs621_als_read_raw()
243 struct iqs621_als_private *iqs621_als = iio_priv(indio_dev); in iqs621_als_read_event_config() local
246 mutex_lock(&iqs621_als->lock); in iqs621_als_read_event_config()
250 ret = iqs621_als->light_en; in iqs621_als_read_event_config()
254 ret = iqs621_als->range_en; in iqs621_als_read_event_config()
258 ret = iqs621_als->prox_en; in iqs621_als_read_event_config()
265 mutex_unlock(&iqs621_als->lock); in iqs621_als_read_event_config()
276 struct iqs621_als_private *iqs621_als = iio_priv(indio_dev); in iqs621_als_write_event_config() local
277 struct iqs62x_core *iqs62x = iqs621_als->iqs62x; in iqs621_als_write_event_config()
281 mutex_lock(&iqs621_als->lock); in iqs621_als_write_event_config()
286 iqs621_als->als_flags = val; in iqs621_als_write_event_config()
292 iqs621_als->range_en || state ? 0 : in iqs621_als_write_event_config()
295 iqs621_als->light_en = state; in iqs621_als_write_event_config()
301 iqs621_als->light_en || state ? 0 : in iqs621_als_write_event_config()
304 iqs621_als->range_en = state; in iqs621_als_write_event_config()
311 iqs621_als->ir_flags = val; in iqs621_als_write_event_config()
317 iqs621_als->prox_en = state; in iqs621_als_write_event_config()
325 mutex_unlock(&iqs621_als->lock); in iqs621_als_write_event_config()
337 struct iqs621_als_private *iqs621_als = iio_priv(indio_dev); in iqs621_als_read_event_value() local
340 mutex_lock(&iqs621_als->lock); in iqs621_als_read_event_value()
344 *val = iqs621_als->thresh_light * 16; in iqs621_als_read_event_value()
348 *val = iqs621_als->thresh_dark * 4; in iqs621_als_read_event_value()
352 if (iqs621_als->ir_flags_mask == IQS622_IR_FLAGS_TOUCH) in iqs621_als_read_event_value()
353 *val = iqs621_als->thresh_prox * 4; in iqs621_als_read_event_value()
355 *val = iqs621_als->thresh_prox; in iqs621_als_read_event_value()
362 mutex_unlock(&iqs621_als->lock); in iqs621_als_read_event_value()
374 struct iqs621_als_private *iqs621_als = iio_priv(indio_dev); in iqs621_als_write_event_value() local
375 struct iqs62x_core *iqs62x = iqs621_als->iqs62x; in iqs621_als_write_event_value()
380 mutex_lock(&iqs621_als->lock); in iqs621_als_write_event_value()
387 thresh_cache = &iqs621_als->thresh_light; in iqs621_als_write_event_value()
395 thresh_cache = &iqs621_als->thresh_dark; in iqs621_als_write_event_value()
432 thresh_cache = &iqs621_als->thresh_prox; in iqs621_als_write_event_value()
447 iqs621_als->ir_flags_mask = ir_flags_mask; in iqs621_als_write_event_value()
450 mutex_unlock(&iqs621_als->lock); in iqs621_als_write_event_value()
544 struct iqs621_als_private *iqs621_als; in iqs621_als_probe() local
549 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*iqs621_als)); in iqs621_als_probe()
553 iqs621_als = iio_priv(indio_dev); in iqs621_als_probe()
554 iqs621_als->iqs62x = iqs62x; in iqs621_als_probe()
555 iqs621_als->indio_dev = indio_dev; in iqs621_als_probe()
562 iqs621_als->thresh_prox = val; in iqs621_als_probe()
563 iqs621_als->ir_flags_mask = IQS622_IR_FLAGS_TOUCH; in iqs621_als_probe()
572 iqs621_als->thresh_light = val; in iqs621_als_probe()
578 iqs621_als->thresh_dark = val; in iqs621_als_probe()
588 mutex_init(&iqs621_als->lock); in iqs621_als_probe()
590 iqs621_als->notifier.notifier_call = iqs621_als_notifier; in iqs621_als_probe()
591 ret = blocking_notifier_chain_register(&iqs621_als->iqs62x->nh, in iqs621_als_probe()
592 &iqs621_als->notifier); in iqs621_als_probe()
600 iqs621_als); in iqs621_als_probe()