18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * ALSA interface to ivtv PCM capture streams 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2009,2012 Andy Walls <awalls@md.metrocast.net> 68c2ecf20Sopenharmony_ci * Copyright (C) 2009 Devin Heitmueller <dheitmueller@kernellabs.com> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistruct snd_card; 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistruct snd_ivtv_card { 128c2ecf20Sopenharmony_ci struct v4l2_device *v4l2_dev; 138c2ecf20Sopenharmony_ci struct snd_card *sc; 148c2ecf20Sopenharmony_ci unsigned int capture_transfer_done; 158c2ecf20Sopenharmony_ci unsigned int hwptr_done_capture; 168c2ecf20Sopenharmony_ci struct snd_pcm_substream *capture_pcm_substream; 178c2ecf20Sopenharmony_ci spinlock_t slock; 188c2ecf20Sopenharmony_ci}; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciextern int ivtv_alsa_debug; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* 238c2ecf20Sopenharmony_ci * File operations that manipulate the encoder or video or audio subdevices 248c2ecf20Sopenharmony_ci * need to be serialized. Use the same lock we use for v4l2 file ops. 258c2ecf20Sopenharmony_ci */ 268c2ecf20Sopenharmony_cistatic inline void snd_ivtv_lock(struct snd_ivtv_card *itvsc) 278c2ecf20Sopenharmony_ci{ 288c2ecf20Sopenharmony_ci struct ivtv *itv = to_ivtv(itvsc->v4l2_dev); 298c2ecf20Sopenharmony_ci mutex_lock(&itv->serialize_lock); 308c2ecf20Sopenharmony_ci} 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistatic inline void snd_ivtv_unlock(struct snd_ivtv_card *itvsc) 338c2ecf20Sopenharmony_ci{ 348c2ecf20Sopenharmony_ci struct ivtv *itv = to_ivtv(itvsc->v4l2_dev); 358c2ecf20Sopenharmony_ci mutex_unlock(&itv->serialize_lock); 368c2ecf20Sopenharmony_ci} 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define IVTV_ALSA_DBGFLG_WARN (1 << 0) 398c2ecf20Sopenharmony_ci#define IVTV_ALSA_DBGFLG_INFO (1 << 1) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define IVTV_ALSA_DEBUG(x, type, fmt, args...) \ 428c2ecf20Sopenharmony_ci do { \ 438c2ecf20Sopenharmony_ci if ((x) & ivtv_alsa_debug) \ 448c2ecf20Sopenharmony_ci pr_info("%s-alsa: " type ": " fmt, \ 458c2ecf20Sopenharmony_ci v4l2_dev->name , ## args); \ 468c2ecf20Sopenharmony_ci } while (0) 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define IVTV_ALSA_DEBUG_WARN(fmt, args...) \ 498c2ecf20Sopenharmony_ci IVTV_ALSA_DEBUG(IVTV_ALSA_DBGFLG_WARN, "warning", fmt , ## args) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define IVTV_ALSA_DEBUG_INFO(fmt, args...) \ 528c2ecf20Sopenharmony_ci IVTV_ALSA_DEBUG(IVTV_ALSA_DBGFLG_INFO, "info", fmt , ## args) 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define IVTV_ALSA_ERR(fmt, args...) \ 558c2ecf20Sopenharmony_ci pr_err("%s-alsa: " fmt, v4l2_dev->name , ## args) 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define IVTV_ALSA_WARN(fmt, args...) \ 588c2ecf20Sopenharmony_ci pr_warn("%s-alsa: " fmt, v4l2_dev->name , ## args) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#define IVTV_ALSA_INFO(fmt, args...) \ 618c2ecf20Sopenharmony_ci pr_info("%s-alsa: " fmt, v4l2_dev->name , ## args) 62