UVC missing controls

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
LBence91
Level 4
Level 4
10 questions asked 50 sign-ins 25 replies posted

Hello,

 I have a UVC firmware based on the AN75779. I want to to set the sensor properties during operation, and for that I modified the Processing Unit descriptor to enable multiple controls. If I check the descriptors(usb view) it says the controls enabled, but if I want to reach these controls via amCap or windows camera app it only shows the brightness and contrast controls, and from this only the brightness works properly. I attached the uvc.c and descriptor file (my device works as a highspeed device). I not sure what am I missing, I thought for more control I only have to change the descriptor and adding the proper requests in the uvc.c file.

Best Regards,

Bence

 

controls.PNG

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Biren_R
Moderator
Moderator
Moderator
First question asked First like given 250 sign-ins

Hi Bence,

Please find attached the example code for UVC+CDC this example has working CCD and control.

Regards,
Biren

View solution in original post

0 Likes
12 Replies
Biren_R
Moderator
Moderator
Moderator
First question asked First like given 250 sign-ins

Hi Bence,

You need to set 
bmControls of Processing Unit Descriptor of CyFxUSBSSConfigDscr array in cyfxuvcdscr.c file based on your control requirements. 

I can see in your code it's 01 so just brightness is only enabled, so you need enable it and handle it in UVCHandleProcessingUnitRqts.

Regards,
Biren

0 Likes

Hello Brien,

Thank you for your response.  I modified the bmControls in the CyFxUSBSSConfigDscr, but my device using the CyFxUSBHSConfigDscr array and the bmcontrfol field of the Processing Unit Descriptor is 0xFF,0x02,0x00, in the High speed section. And if I check the descriptors in the usb view application i can read back this value(picture attached). Is in there any other part of the uvc.c code or the cyfxuvcdscr.c which need to be modified for the control implementation?

Best Regards,

Bence

pudesc.PNG

0 Likes
Biren_R
Moderator
Moderator
Moderator
First question asked First like given 250 sign-ins

Hi Bence,

You need to handle it in UVCHandleProcessingUnitRqts under uvc.c.

Regards,
Biren

0 Likes

Hi Biren,

I thought I did, but doesn't matter how many plus control I add only the brightness and contrast shows up as usable controls and the contrast has a bug, it can not be modified.

static void
UVCHandleProcessingUnitRqts (
		void)
{
	CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
	uint16_t readCount, brightnessVal, contrastVal;

	switch (wValue)
	{
	CyU3PDebugPrint (4, "Req: %d...\r\n",wValue);
	case CY_FX_UVC_PU_BRIGHTNESS_CONTROL:
		switch (bRequest)
		{
		case CY_FX_USB_UVC_GET_LEN_REQ: /* Length of brightness data = 2 byte. */
			glEp0Buffer[0] = 2;
			CyU3PDebugPrint (4, "GET_LEN...\r\n");
			CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
			break;
		case CY_FX_USB_UVC_GET_CUR_REQ: /* Current brightness value. */
			glEp0Buffer[0] = SensorGetAGC();
			CyU3PDebugPrint (4, "GET_CUR...\r\n");
			CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
			break;
		case CY_FX_USB_UVC_GET_MIN_REQ: /* Minimum brightness = 0. */
			glEp0Buffer[0] = 0;
			CyU3PDebugPrint (4, "GET_MIN...\r\n");
			CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
			break;
		case CY_FX_USB_UVC_GET_MAX_REQ: /* Maximum brightness = 255. */
			glEp0Buffer[0] = 255;
			CyU3PDebugPrint (4, "GET_MAX...\r\n");
			CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
			break;
		case CY_FX_USB_UVC_GET_RES_REQ: /* Resolution = 1. */
			glEp0Buffer[0] = 1;
			CyU3PDebugPrint (4, "GET_RES...\r\n");
			CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
			break;
		case CY_FX_USB_UVC_GET_INFO_REQ: /* Both GET and SET requests are supported, auto modes not supported */
			glEp0Buffer[0] = 3;
			CyU3PDebugPrint (4, "GET_INFO...\r\n");
			CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
			break;
		case CY_FX_USB_UVC_GET_DEF_REQ: /* Default brightness value = 65. */
			glEp0Buffer[0] = 65;
			CyU3PDebugPrint (4, "GET_DEF...\r\n");
			CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
			break;
		case CY_FX_USB_UVC_SET_CUR_REQ: /* Update brightness value. */
			apiRetStatus = CyU3PUsbGetEP0Data (CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED,
					glEp0Buffer, &readCount);
			if (apiRetStatus == CY_U3P_SUCCESS)
			{
				CyU3PDebugPrint (4, "SET_Gain...\r\n");
				// Update the brightness value only if the value is within the range
				brightnessVal = glEp0Buffer[0];//CY_U3P_MAKEWORD(glEp0Buffer[1], glEp0Buffer[0]);
				//SensorSetBrightness (glEp0Buffer[0]);
				SensorSetAGC(glEp0Buffer[0]);
				CyU3PDebugPrint (4, "SET_AGC: %d\r\n",brightnessVal);
				if(brightnessVal >= 0 && brightnessVal <= 255)
				{
					//SensorSetBrightness (glEp0Buffer[0]);
					//SensorSetAEC(glEp0Buffer[0]);
				}
			}
			break;
		default:
			glUvcVcErrorCode = CY_FX_UVC_VC_ERROR_CODE_INVALID_REQUEST;
			CyU3PUsbStall (0, CyTrue, CyFalse);
			break;

		}
		break;
		case CY_FX_UVC_PU_CONTRAST_CONTROL:
			switch (bRequest)
			{
			case CY_FX_USB_UVC_GET_LEN_REQ: /* Length of brightness data = 2 byte. */
				glEp0Buffer[0] = 2;
				CyU3PDebugPrint (4, "GET_LEN...\r\n");
				CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
				break;
			case CY_FX_USB_UVC_GET_CUR_REQ: /* Current brightness value. */
				glEp0Buffer[0] = SensorGetAEC();//L(); //SensorGetXL();
				CyU3PDebugPrint (4, "GET_CUR...\r\n");
				CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
				break;
			case CY_FX_USB_UVC_GET_MIN_REQ: /* Minimum brightness = 0. */
				glEp0Buffer[0] = 0;
				CyU3PDebugPrint (4, "GET_MIN...\r\n");
				CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
				break;
			case CY_FX_USB_UVC_GET_MAX_REQ: /* Maximum brightness = 255. */
				glEp0Buffer[0] = 255;
				CyU3PDebugPrint (4, "GET_MAX...\r\n");
				CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
				break;
			case CY_FX_USB_UVC_GET_RES_REQ: /* Resolution = 1. */
				glEp0Buffer[0] = 1;
				CyU3PDebugPrint (4, "GET_RES...\r\n");
				CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
				break;
			case CY_FX_USB_UVC_GET_INFO_REQ: /* Both GET and SET requests are supported, auto modes not supported */
				glEp0Buffer[0] = 3;
				CyU3PDebugPrint (4, "GET_INFO...\r\n");
				CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
				break;
			case CY_FX_USB_UVC_GET_DEF_REQ: /* Default brightness value = 55. */
				glEp0Buffer[0] = 55;
				CyU3PDebugPrint (4, "GET_DEF...\r\n");
				CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
				break;
			case CY_FX_USB_UVC_SET_CUR_REQ: /* Update brightness value. */
				apiRetStatus = CyU3PUsbGetEP0Data (CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED,
						glEp0Buffer, &readCount);
				contrastVal = CY_U3P_MAKEWORD(glEp0Buffer[1], glEp0Buffer[0]);
				contrastVal = glEp0Buffer[0];
				CyU3PDebugPrint (4, "SET_AEC: %d\r\n",contrastVal);
				if (apiRetStatus == CY_U3P_SUCCESS)
				{
					//CyU3PDebugPrint (4, "SET_gain...\r\n");
					//SensorSetAEC(glEp0Buffer[0]);
				}
				break;
			default:

				glUvcVcErrorCode = CY_FX_UVC_VC_ERROR_CODE_INVALID_CONTROL;
				CyU3PUsbStall (0, CyTrue, CyFalse);
				break;
			}
			break;
			case CY_FX_UVC_PU_HUE_CONTROL:
				switch (bRequest)
				{
				case CY_FX_USB_UVC_GET_LEN_REQ: /* Length of brightness data = 2 byte. */
					glEp0Buffer[0] = 2;
					CyU3PDebugPrint (4, "GET_LEN...\r\n");
					CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
					break;
				case CY_FX_USB_UVC_GET_CUR_REQ: /* Current brightness value. */
					glEp0Buffer[0] = SensorGetAEC();//L(); //SensorGetXL();
					CyU3PDebugPrint (4, "GET_CUR...\r\n");
					CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
					break;
				case CY_FX_USB_UVC_GET_MIN_REQ: /* Minimum brightness = 0. */
					glEp0Buffer[0] = 0;
					CyU3PDebugPrint (4, "GET_MIN...\r\n");
					CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
					break;
				case CY_FX_USB_UVC_GET_MAX_REQ: /* Maximum brightness = 255. */
					glEp0Buffer[0] = 255;
					CyU3PDebugPrint (4, "GET_MAX...\r\n");
					CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
					break;
				case CY_FX_USB_UVC_GET_RES_REQ: /* Resolution = 1. */
					glEp0Buffer[0] = 1;
					CyU3PDebugPrint (4, "GET_RES...\r\n");
					CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
					break;
				case CY_FX_USB_UVC_GET_INFO_REQ: /* Both GET and SET requests are supported, auto modes not supported */
					glEp0Buffer[0] = 3;
					CyU3PDebugPrint (4, "GET_INFO...\r\n");
					CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
					break;
				case CY_FX_USB_UVC_GET_DEF_REQ: /* Default brightness value = 55. */
					glEp0Buffer[0] = 55;
					CyU3PDebugPrint (4, "GET_DEF...\r\n");
					CyU3PUsbSendEP0Data (2, (uint8_t *)glEp0Buffer);
					break;
				case CY_FX_USB_UVC_SET_CUR_REQ: /* Update brightness value. */
					apiRetStatus = CyU3PUsbGetEP0Data (CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED,
							glEp0Buffer, &readCount);
					contrastVal = CY_U3P_MAKEWORD(glEp0Buffer[1], glEp0Buffer[0]);
					contrastVal = glEp0Buffer[0];
					CyU3PDebugPrint (4, "SET_HUE: %d\r\n",contrastVal);
					if (apiRetStatus == CY_U3P_SUCCESS)
					{
						//CyU3PDebugPrint (4, "SET_gain...\r\n");
						//SensorSetAEC(glEp0Buffer[0]);
					}
					break;
				default:

					glUvcVcErrorCode = CY_FX_UVC_VC_ERROR_CODE_INVALID_CONTROL;
					CyU3PUsbStall (0, CyTrue, CyFalse);
					break;
				}
				break;
	}

 

0 Likes
Biren_R
Moderator
Moderator
Moderator
First question asked First like given 250 sign-ins

Hi Bence,

I tested with the default UVC_AN75779 example and your changes look like it's working, i think you still using SSUSB, not HSUSB you need to change CyU3PConnectState (CyTrue, CyFalse); in UVC .c which select USB HS. 

Regards,
Biren

0 Likes

Hi Biren,

I modified connectstate function, but got the same result. I tried implementing multiple control requests, and I always got the same result. So if i implement more than 1 control, I only can set the brightness properly and the second one got the start value, but if I try to change it sending zeros only. I have debug messages also from the phenomena. Is the debug print backend capable to influence the UVC requests?

Best Regards,

Bence

comit.PNG

amcapcont.PNG

0 Likes
Biren_R
Moderator
Moderator
Moderator
First question asked First like given 250 sign-ins

Hi Bence,

I suggest you can use default AN75779 FW and just change below point you should get control in UVC app.

1. change to HS mode by updating CyU3PConnectState (CyTrue, CyFalse); in UVC.c
2. change bmControls Processing Unit Descriptor of CyFxUSBHSConfigDscr to 0xFF,0x02,0x00 in cyfxuvcdscr.c
3. update UVCHandleProcessingUnitRqts in UVC.c as you posted in previous replay.

If still you not get it working then please share your code, we will like to preproduce it at our end.

Regards,
Biren

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Biren,

I checked these steps, and got still the same results. My project based on the AN75779 so I attached the modified files. I am eager to know what is my mistake.

Best Regards,

Bence

0 Likes
lock attach
Attachments are accessible only for community members.
Biren_R
Moderator
Moderator
Moderator
First question asked First like given 250 sign-ins

Hi Bence,

can you please test with the attached uvc.c file you had not added all control requests and DebugInit(); created issue so I just commented it.

Regards,
Biren

0 Likes

Hi Biren,

Yes that can solve the bug, but if I comment out the debuginit, I am not able to use the debug prints. It is a custom board and I need to send messages via COM port. Is there a way to keep this function and the controls too? What is the connection between the debug prints and the camera control requests?

Regards,

Bence

0 Likes
lock attach
Attachments are accessible only for community members.
Biren_R
Moderator
Moderator
Moderator
First question asked First like given 250 sign-ins

Hi Bence,

Please find attached the example code for UVC+CDC this example has working CCD and control.

Regards,
Biren

0 Likes

Hi Biren,

This project works, thank you very much.

Best Regards,

Bence

0 Likes