How to get number of audio device connected and its capabilities on TX2

Hi Nvidia,

I want to detect which all audio device connected to Tx2 BOARD, and which of them are recording.
kindly any one can guide how to go about, i tried many thing but didn’t worked. Below are the details.

Kindly help ,thanks

I have done for video device connected like (HDMI input camera & USB camera) using APIS.
But not able to do for audio status or audio capabilities.

for like video:

Video Src detection

snprintf(cBuff,CAM_BUFF_LEN,"/dev/video%d",nVIdx);

		if((nFd = open(cBuff, O_RDONLY)) == -1)
		{
			
		}

		if (ioctl(nFd,VIDIOC_G_INPUT , &nIndex) == -1)
		{
			perror("\n VIDIOC_G_INPUT FAILURE \n");
		}
		
		if (ioctl(nFd, VIDIOC_ENUMINPUT, &stInput) == -1)
		{
			perror("\n VIDIOC_ENUMINPUT FAILURE \n");
		}


Video src capabilities:

stFmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	while ((nRet = ioctl(nCamera_fd, VIDIOC_ENUM_FMT, &stFmtdesc)) == 0)
	{
		sCamFmt = stFmtdesc.pixelformat & 0xFF;
		sCamFmt += (stFmtdesc.pixelformat >> 8) & 0xFF;
		sCamFmt += (stFmtdesc.pixelformat >> 16) & 0xFF;
		sCamFmt += (stFmtdesc.pixelformat >> 24) & 0xFF;
	}

	stFmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	if (ioctl(nCamera_fd, VIDIOC_G_FMT, &stFmt) < 0)
	{
		nReturn = FAILURE;
	}

for like Audio:I have tried using VIDIOC_ENUMAUDIO but getting this error.
: Inappropriate ioctl for devic


                        struct v4l2_audio audio;
                         snprintf(cBuff,CAM_BUFF_LEN,"/dev/video%d",nVIdx);

			if((nFd = open(cBuff, O_RDONLY)) == -1)
			{
				if(nVIdx == 0)
				{
					perror("\n No Cam device Found \n");
				}
				close(nFd);
				break;
			}

			if (ioctl(nFd,VIDIOC_G_INPUT , &nIndex) == -1)
			{
				perror("\n VIDIOC_G_INPUT FAILURE \n");
			}

			memset(&audio, 0, sizeof(audio));
			audio.index = nIndex;

			//  VIDIOC_ENUMINPUT VIDIOC_ENUMAUDIO
			if (ioctl(nFd, VIDIOC_ENUMAUDIO , &stInput) == -1)
			{
				perror("\n  VIDIOC_ENUMAUDIO FAILURE \n");
			}

[b]For audio src Detection : ?

For audio capabilities : ?[/b]

@meRaza
Below command can get some audio information. More detail you should find some ALSA document and tools

cat /proc/asound/cards
arecord -l

Hi Shane,
Thnak d for your reply , i was looking in a programmatic way, as example code uses ioctl function calls to set and get camera setting , capabilities… etc. Like wise for audio any example code for detection or audio capabilities.

Thanks

Hello!

Per Shane’s response, the best examples to look at are the aplay and arecord utilities [0]. As Shane mention ‘arecord -l’ will provide a list of devices that can record. If you want to see what this command is doing please take a look at the source [1].

Regards,
Jon

[0] git.alsa-project.org Git - alsa-utils.git/summary
[1] git.alsa-project.org Git - alsa-utils.git/blob - aplay/aplay.c