Page MenuHomeFreeBSD

Set default alternate setting when USB audio devices are not in use, to activate power save features.
AbandonedPublic

Authored by hselasky on Jan 8 2021, 3:19 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 22, 2:34 AM
Unknown Object (File)
Tue, Oct 22, 2:34 AM
Unknown Object (File)
Tue, Oct 22, 2:19 AM
Unknown Object (File)
Fri, Oct 18, 9:20 AM
Unknown Object (File)
Mon, Oct 14, 1:02 AM
Unknown Object (File)
Oct 3 2024, 9:53 PM
Unknown Object (File)
Oct 3 2024, 4:35 PM
Unknown Object (File)
Oct 2 2024, 7:42 PM

Details

Summary

Set default alternate setting when USB audio devices are not
in use, to activate power save features.

Suggested by: Shichun_Ma@Dell.com
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

khng added inline comments.
sys/dev/sound/pcm/channel_if.m
160 ↗(On Diff #81864)

You should make a default kobj method for prepare() so that it returns (0) for drivers that doesn't need to implement this method.

I suggest the following additions:

sys/dev/sound/pcm/channel_if.m

CODE {
	static int
	channel_noprepare(kobj_t obj, void *data, int go)
	{
		return (0);
	}
};

METHOD int prepare {
	kobj_t obj;
	void *data;
	int go;
} DEFAULT channel_noprepare;
sys/dev/sound/pcm/vchan.c
199 ↗(On Diff #81864)

It's more formal to return 0 to indicate success here?
nits: return (x) for style(9)-compliance.

sys/dev/sound/usb/uaudio_pcm.c
86 ↗(On Diff #81864)

nits: return (x) for style(9)-compliance.

sys/dev/sound/pcm/channel.h
371 ↗(On Diff #81864)

This flag seems unused. Do you want to set this if channel_prepare method succeeds?

sys/dev/sound/usb/uaudio.c
2823

Chan compare must use the configure message callback API, else this control request might end up out of order!

2863–2864

Why can't you just set:

ch->cur_alt_index = 0;

Here ?

2869

Adding this call here is wrong and will race!

sys/dev/sound/usb/uaudio.c
2869

Changing configuration and/or interfaces is only allowed from the USB explore process!

Is it OK if this issue can wait until after 13 is out?

BTW: Did you get my comments?

--HPS

@hselasky , the set chan prepare operation need wait configure message callback API finished.
I don't have good method to do that, while usually xfer starts after set alt interface.
It's ok to submit this to mainstream, this change may impact others and can be improved.

Like said:
Channel prepare must use the configure message callback API, else this control request might end up out of order!

This patch is not yet ready for upstreaming. Please fix!

This revision now requires changes to proceed.Feb 10 2021, 4:05 AM

I might have some time later this month to help prepare a patch the way I think is more correct to implement this.

@hselasky , expecting to see your patch, and I stand by to do any test.

sys/dev/sound/pcm/channel.h
371 ↗(On Diff #81864)

I may use this before while no need to use this flag.

sys/dev/sound/pcm/channel_if.m
160 ↗(On Diff #81864)

Could you explain why need such default kobj method?

It is to make sure that (0) is returned consistently in case your method is
going to be used elsewhere by e.g. other 3rd parties, and when not all
drivers implemented this. Otherwise for drivers not implementing this
method (ENXIO) would be returned. This makes the return value less
confusing in such case.

I'll try to get some work done here once 13 is out. This will be a new feature :-)

Thank you for your patience.

This revision now requires review to proceed.Mar 9 2021, 4:45 PM
hselasky retitled this revision from add interface set 0/alter when start/stop play/record audio to Set default alternate setting when USB audio devices are not in use, to activate power save features..
hselasky edited the summary of this revision. (Show Details)
hselasky edited the test plan for this revision. (Show Details)

@shichun_ma_dell.com : Can you test this patch?

No need to do anything in the callback thread upon drain.