From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753948AbYKSNuH (ORCPT ); Wed, 19 Nov 2008 08:50:07 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753212AbYKSNty (ORCPT ); Wed, 19 Nov 2008 08:49:54 -0500 Received: from cantor2.suse.de ([195.135.220.15]:38818 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753205AbYKSNtx (ORCPT ); Wed, 19 Nov 2008 08:49:53 -0500 Date: Wed, 19 Nov 2008 14:49:52 +0100 Message-ID: From: Takashi Iwai To: "Bryan Wu" Cc: "ALSA devel" , LKML Subject: Re: [Question] Can I open a substream in kernel space without attach to a file pointer? In-Reply-To: <386072610811190200l576d7735rb0188ab53f5185fa@mail.gmail.com> References: <386072610811190200l576d7735rb0188ab53f5185fa@mail.gmail.com> User-Agent: Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-8859-4?Q?Sanj=F2?=) APEL/10.6 Emacs/22.3 (x86_64-suse-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At Wed, 19 Nov 2008 18:00:36 +0800, Bryan Wu wrote: > > Hi Takashi, > > I am developing a USB gadget driver compliant to USB Audio Class Spec 2.0. > So I want to open a PCM substream and do some playback of capture, > then close them? > > I found snd_pcm_open_substream() is for opening a substream and attach > it to a file. > But in my application, there is no need to open a file before opening > a substream. > > - Is there any interface for me to open a substream in kernel space > without attach to a file? > - How to playback and capture in kernel space, use snd_pcm_lib_write > and snd_pcm_lib_read? > - How to get the snd_pcm_hardware struct from low level driver, > because I have to get the hardware configuration of the snd pcm > device? > > And I am reading the code of OSS emulator in ALSA. It provides some > info about the kernel space sound card programming. Yes, OSS emulation code handles the PCM in the kernel. But, basically I don't recommend you to do this -- it's not the job of the sound card driver. The whole PCM stuff is handled by the PCM middle layer, not the driver itself. Any reason why you handle the PCM stuff completely in your driver code? Takashi