[Sound-open-firmware] [RFC PATCH v2] tone: add command handler to return tone state and compute tone sample rate

Liam Girdwood liam.r.girdwood at linux.intel.com
Mon Jun 11 11:47:36 CEST 2018


On Sun, 2018-06-10 at 18:25 -0700, Ranjani Sridharan wrote:
> On Sun, 2018-06-10 at 21:11 +0100, Liam Girdwood wrote:
> > On Fri, 2018-06-08 at 23:29 -0700, Ranjani Sridharan wrote:
> > > This patch adds the get() handler to respond to requests for the
> > > current
> > > tone state.
> > > 
> > > It also modifies the set() handler to return the
> > > previous state in the ipc reply. This will help the driver in
> > > determining if the tone pipeline needs to be triggered or not.
> > 
> > Why does the driver need to know this after set() ?
> 
> This is because right after the user sets a new state, the pipeline
> state may need to change. In the case of state change to ON, if the
> pipeline is already enabled, we should notify the driver so it doesnt
> try to re-enable the pipeline ir send ipc to set pcm params and trigger
> start. 

Component should ignore this, userspace only knows the state by calling get().
Tone should always be OFF unless enabled by userspace.

Liam

> 
> > 
> > > 
> > > Lastly, it modifies the tone sample rate to be computed from the
> > > pipeline deadline and frames per sched.
> > 
> > Btw, this should probably be 3 patches (since it does different 3
> > things).
> 
> OK, I will split it up. 
> > 
> > Liam
> > 
> > > 
> > > Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com
> > > > 
> > > 
> > > ---
> > >  src/audio/tone.c | 28 +++++++++++++++++++++++++++-
> > >  1 file changed, 27 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/src/audio/tone.c b/src/audio/tone.c
> > > index eee6091..839a0f6 100644
> > > --- a/src/audio/tone.c
> > > +++ b/src/audio/tone.c
> > > @@ -462,6 +462,25 @@ static int tone_params(struct comp_dev *dev)
> > >  	return 0;
> > >  }
> > >  
> > > +static int tone_cmd_get_value(struct comp_dev *dev,
> > > +			      struct sof_ipc_ctrl_data *cdata)
> > > +{
> > > +	struct comp_data *cd = comp_get_drvdata(dev);
> > > +	int j;
> > > +
> > > +	trace_tone("mgt");
> > > +
> > > +	if (cdata->cmd == SOF_CTRL_CMD_SWITCH) {
> > > +		for (j = 0; j < cdata->num_elems; j++) {
> > > +			cdata->chanv[j].channel = j;
> > > +			cdata->chanv[j].value = !cd->sg[j].mute;
> > > +			trace_value(j);
> > > +			trace_value(cd->sg[j].mute);
> > > +		}
> > > +	}
> > > +	return 0;
> > > +}
> > > +
> > >  static int tone_cmd_set_value(struct comp_dev *dev, struct
> > > sof_ipc_ctrl_data
> > > *cdata)
> > >  {
> > >  	struct comp_data *cd = comp_get_drvdata(dev);
> > > @@ -480,6 +499,10 @@ static int tone_cmd_set_value(struct comp_dev
> > > *dev,
> > > struct sof_ipc_ctrl_data *cd
> > >  				trace_tone_error("che");
> > >  				return -EINVAL;
> > >  			}
> > > +
> > > +			/* send current state back to the driver
> > > */
> > > +			cdata->chanv[j].value = !cd->sg[ch].mute;
> > > +
> > >  			if (val)
> > >  				tonegen_unmute(&cd->sg[ch]);
> > >  			else
> > > @@ -583,6 +606,9 @@ static int tone_cmd(struct comp_dev *dev, int
> > > cmd, void
> > > *data)
> > >  	case COMP_CMD_SET_VALUE:
> > >  		ret = tone_cmd_set_value(dev, cdata);
> > >  		break;
> > > +	case COMP_CMD_GET_VALUE:
> > > +		ret = tone_cmd_get_value(dev, cdata);
> > > +		break;
> > >  	}
> > >  
> > >  	return ret;
> > > @@ -641,7 +667,7 @@ static int tone_prepare(struct comp_dev * dev)
> > >  		return ret;
> > >  
> > >  	cd->channels = dev->params.channels;
> > > -	cd->rate = dev->params.rate;
> > > +	cd->rate = dev->frames * dev->pipeline->ipc_pipe.deadline;
> > >  	tracev_value(cd->channels);
> > >  	tracev_value(cd->rate);
> > >  
> 
> _______________________________________________
> Sound-open-firmware mailing list
> Sound-open-firmware at alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/sound-open-firmware


More information about the Sound-open-firmware mailing list