| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Jack abstraction layer |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2008 Wolfson Microelectronics |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program; if not, write to the Free Software |
|---|
| 18 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | | - * |
|---|
| 20 | 6 | */ |
|---|
| 21 | 7 | |
|---|
| 22 | 8 | #include <linux/input.h> |
|---|
| .. | .. |
|---|
| 33 | 19 | }; |
|---|
| 34 | 20 | |
|---|
| 35 | 21 | #ifdef CONFIG_SND_JACK_INPUT_DEV |
|---|
| 36 | | -static int jack_switch_types[] = { |
|---|
| 22 | +static const int jack_switch_types[SND_JACK_SWITCH_TYPES] = { |
|---|
| 37 | 23 | SW_HEADPHONE_INSERT, |
|---|
| 38 | 24 | SW_MICROPHONE_INSERT, |
|---|
| 39 | 25 | SW_LINEOUT_INSERT, |
|---|
| 40 | 26 | SW_JACK_PHYSICAL_INSERT, |
|---|
| 41 | 27 | SW_VIDEOOUT_INSERT, |
|---|
| 42 | 28 | SW_LINEIN_INSERT, |
|---|
| 43 | | - SW_HPHL_OVERCURRENT, |
|---|
| 44 | | - SW_HPHR_OVERCURRENT, |
|---|
| 45 | | - SW_UNSUPPORT_INSERT, |
|---|
| 46 | | - SW_MICROPHONE2_INSERT, |
|---|
| 47 | 29 | }; |
|---|
| 48 | 30 | #endif /* CONFIG_SND_JACK_INPUT_DEV */ |
|---|
| 49 | 31 | |
|---|
| .. | .. |
|---|
| 222 | 204 | struct snd_jack *jack; |
|---|
| 223 | 205 | struct snd_jack_kctl *jack_kctl = NULL; |
|---|
| 224 | 206 | int err; |
|---|
| 225 | | - static struct snd_device_ops ops = { |
|---|
| 207 | + static const struct snd_device_ops ops = { |
|---|
| 226 | 208 | .dev_free = snd_jack_dev_free, |
|---|
| 227 | 209 | #ifdef CONFIG_SND_JACK_INPUT_DEV |
|---|
| 228 | 210 | .dev_register = snd_jack_dev_register, |
|---|
| .. | .. |
|---|
| 261 | 243 | |
|---|
| 262 | 244 | jack->type = type; |
|---|
| 263 | 245 | |
|---|
| 264 | | - for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++) |
|---|
| 246 | + for (i = 0; i < SND_JACK_SWITCH_TYPES; i++) |
|---|
| 265 | 247 | if (type & (1 << i)) |
|---|
| 266 | 248 | input_set_capability(jack->input_dev, EV_SW, |
|---|
| 267 | 249 | jack_switch_types[i]); |
|---|
| .. | .. |
|---|
| 366 | 348 | { |
|---|
| 367 | 349 | struct snd_jack_kctl *jack_kctl; |
|---|
| 368 | 350 | #ifdef CONFIG_SND_JACK_INPUT_DEV |
|---|
| 351 | + struct input_dev *idev; |
|---|
| 369 | 352 | int i; |
|---|
| 370 | 353 | #endif |
|---|
| 371 | 354 | |
|---|
| .. | .. |
|---|
| 377 | 360 | status & jack_kctl->mask_bits); |
|---|
| 378 | 361 | |
|---|
| 379 | 362 | #ifdef CONFIG_SND_JACK_INPUT_DEV |
|---|
| 380 | | - if (!jack->input_dev) |
|---|
| 363 | + idev = input_get_device(jack->input_dev); |
|---|
| 364 | + if (!idev) |
|---|
| 381 | 365 | return; |
|---|
| 382 | 366 | |
|---|
| 383 | 367 | for (i = 0; i < ARRAY_SIZE(jack->key); i++) { |
|---|
| 384 | 368 | int testbit = SND_JACK_BTN_0 >> i; |
|---|
| 385 | 369 | |
|---|
| 386 | 370 | if (jack->type & testbit) |
|---|
| 387 | | - input_report_key(jack->input_dev, jack->key[i], |
|---|
| 371 | + input_report_key(idev, jack->key[i], |
|---|
| 388 | 372 | status & testbit); |
|---|
| 389 | 373 | } |
|---|
| 390 | 374 | |
|---|
| 391 | 375 | for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++) { |
|---|
| 392 | 376 | int testbit = 1 << i; |
|---|
| 393 | 377 | if (jack->type & testbit) |
|---|
| 394 | | - input_report_switch(jack->input_dev, |
|---|
| 378 | + input_report_switch(idev, |
|---|
| 395 | 379 | jack_switch_types[i], |
|---|
| 396 | 380 | status & testbit); |
|---|
| 397 | 381 | } |
|---|
| 398 | 382 | |
|---|
| 399 | | - input_sync(jack->input_dev); |
|---|
| 383 | + input_sync(idev); |
|---|
| 384 | + input_put_device(idev); |
|---|
| 400 | 385 | #endif /* CONFIG_SND_JACK_INPUT_DEV */ |
|---|
| 401 | 386 | } |
|---|
| 402 | 387 | EXPORT_SYMBOL(snd_jack_report); |
|---|