Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uac c_srate/c_srare attribute suport for multiple samplerates #75

Open
bitkeeper opened this issue Apr 16, 2023 · 3 comments
Open

uac c_srate/c_srare attribute suport for multiple samplerates #75

bitkeeper opened this issue Apr 16, 2023 · 3 comments

Comments

@bitkeeper
Copy link

Since the 5.18+ kernel UAC supportes multiple samplerates. See u_audio.h.

Would it be possible to support this?

@pabs3
Copy link
Member

pabs3 commented Apr 17, 2023 via email

@bitkeeper
Copy link
Author

ok fair.

I couldn't directly found an example of another scheme that is using arrays with regular values.
Can you at least point me in the correct direction where/how to this.

So far I found:

  • uac2.h : modify the struct members to hold the same fields as the kernel driver (change the rates to arrays):
struct usbg_f_uac2_attrs {
	int c_chmask;
	int c_srate[UAC_MAX_RATES]; # < modified
	int c_ssize;
	int p_chmask;
	int p_srate[UAC_MAX_RATES]; # < modified
	int p_ssize;
};


union usbg_f_uac2_attr_val {
	int c_chmask;
	int c_srate[UAC_MAX_RATES]; # < modified
	int c_ssize;
	int p_chmask;
	int p_srate[UAC_MAX_RATES]; # < modified
	int p_ssize;
};

Or is better to use a dynamic list here?

  • next is to uac2.c register different set/get/import/export which are name based
#define UAC2_DEC_ATTR(_name)						\
	{								\
		.name = #_name,						\
		.offset = offsetof(struct usbg_f_uac2_attrs, _name),    \
		.get = usbg_get_dec,				        \
		.set = usbg_set_dec,				        \
		.import = usbg_get_config_node_int,	                \
		.export = usbg_set_config_node_int,		        \
	}

#define UAC2_DEC_ARRAY_ATTR(_name)						\
	{								\
		.name = #_name,						\
		.offset = offsetof(struct usbg_f_uac2_attrs, _name),    \
		.get = usbg_get_dec_array,				        \
		.set = usbg_set_dec_array,				        \
		.import = usbg_get_config_node_int_array,	                \
		.export = usbg_set_config_node_int_array,		        \
	}

static struct {
	const char *name;
	size_t offset;
	usbg_attr_get_func get;
	usbg_attr_set_func set;
	usbg_import_node_func import;
	usbg_export_node_func export;
} uac2_attr[USBG_F_UAC2_ATTR_MAX] = {
	[USBG_F_UAC2_C_CHMASK] = UAC2_DEC_ATTR(c_chmask),
	[USBG_F_UAC2_C_SRATE] = UAC2_DEC_ARRAY_ATTR(c_srate),
	[USBG_F_UAC2_C_SSIZE] = UAC2_DEC_ATTR(c_ssize),
	[USBG_F_UAC2_P_CHMASK] = UAC2_DEC_ATTR(p_chmask),
	[USBG_F_UAC2_P_SRATE] = UAC2_DEC_ARRAY_ATTR(p_srate),
	[USBG_F_UAC2_P_SSIZE] = UAC2_DEC_ATTR(p_ssize),
};
  • And now implement the array functions:
    • usbg_get_dec_array
    • usbg_set_dec_array
    • usbg_get_config_node_int_array - configlib importer
    • usbg_set_config_node_int_array - configlib exporter

What else should be done?

Thanks!

@pabs3
Copy link
Member

pabs3 commented Apr 20, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants