Getting property page displayed and work in AmCap with UVC firmware

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

cross mob
Anonymous
Not applicable

Hi,

   

 

   

I have tried to modify your UVC firmware and have property page (the one lets you adjust brightness, hue, sharpness...etc) displayed and work when running AmCap.exe but I am only able to make property page displayed but all properties scroll bar are grey-out and cannot be adjuested. Any idea what might be the root cause of this issue ? Thanks in advance for any help.

   

Following is what I have done.

   

UVCAppEP0Thread_Entry (
        uint32_t input)
{

    uint32_t flag;
    uint16_t readCount;
    CyU3PReturnStatus_t apiRetStatus;

    for (;;)
    {
        /* Check for UVC class request event */
        /* Wait for or get the status of an event flag group */
#if 1
        //Let's get all 32bit into flag
        if (CyU3PEventGet (&glFxUVCEvent, 0xFFFFFFFF, CYU3P_EVENT_OR_CLEAR, &flag,
                CYU3P_WAIT_FOREVER) == CY_U3P_SUCCESS)
#else
        if (CyU3PEventGet (&glFxUVCEvent, (CY_FX_UVC_GET_CUR_EVENT | CY_FX_UVC_SET_CUR_EVENT |
                           CY_FX_UVC_GET_MIN_EVENT | CY_FX_UVC_GET_MAX_EVENT | CY_FX_UVC_GET_DEF_EVENT |
                           CY_FX_UVC_GET_RES_EVENT),
                           CYU3P_EVENT_OR_CLEAR, &flag,
                           CYU3P_WAIT_FOREVER) == CY_U3P_SUCCESS)
#endif
        {
            /* Check for UVC GET_CUR request event */
            if (flag & CY_FX_UVC_GET_CUR_EVENT)
            {
                //APTINA: Is it a videostreaming request?
                if (flag & CY_FX_UVC_VS_EVENT)
                {
                    CyU3PDebugPrint (4, "It's a CY_FX_UVC_VS_EVENT\n");
                    //if (flag & (CY_FX_UVC_VS_PROBE_CONTROL | CY_FX_UVC_VS_COMMIT_CONTROL))
                    //{
                        /* Host requests for Probe Data of 26 bytes */
                        /* Send 26 bytes of Video Probe Control Data over EP0 */
                        /* */
                        apiRetStatus = CyU3PUsbSendEP0Data(CY_FX_UVC_MAX_PROBE_SETTING, (uint8_t *)glProbeCtrl);
                        if (apiRetStatus != CY_U3P_SUCCESS)
                        {
                            /* Error handling */
                            CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                        }
                    //}
                    //APTINA: TODO=> Take care of CY_FX_UVC_VS_CONTROL_UNDEFINED event and other.
                }
                else //It is a video control request !
                {
                    CyU3PDebugPrint (4, "It's GET_CUR - video control request. Flag = 0x%x\n", flag);
                    if (flag & CY_FX_UVC_BRIGHTNESS_CONTROL)
                    {
                        CyU3PDebugPrint (4, "It's a CY_FX_UVC_BRIGHTNESS_CONTROL\n");
                        EP0BUF[0]= (uint8_t)((cur_brightness & 0xff00)>>8);
                        EP0BUF[1]= (uint8_t)(cur_brightness & 0x00ff);
                        apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                        if (apiRetStatus != CY_U3P_SUCCESS)
                        {
                            /* Error handling */
                            CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                        }

                    }
                    if (flag & CY_FX_UVC_SATURATION_CONTROL)
                    {
                           CyU3PDebugPrint (4, "It's a CY_FX_UVC_SATURATION_CONTROL\n");
                        EP0BUF[0]= (uint8_t)((cur_saturation & 0xff00)>>8);
                        EP0BUF[1]= (uint8_t)(cur_saturation & 0x00ff);
                        apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                        if (apiRetStatus != CY_U3P_SUCCESS)
                        {
                            /* Error handling */
                            CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                        }

                    }
                    if (flag & CY_FX_UVC_CONTRAST_CONTROL)
                    {
                           CyU3PDebugPrint (4, "It's a CY_FX_UVC_CONTRAST_CONTROL\n");
                        EP0BUF[0]= (uint8_t)((cur_contrast & 0xff00)>>8);
                        EP0BUF[1]= (uint8_t)(cur_contrast & 0x00ff);
                        apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                        if (apiRetStatus != CY_U3P_SUCCESS)
                        {
                            /* Error handling */
                            CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                        }

                    }
                    if (flag & CY_FX_UVC_GAMMA_CONTROL)
                    {
                           CyU3PDebugPrint (4, "It's a CY_FX_UVC_GAMMA_CONTROL\n");
                        EP0BUF[0]= (uint8_t)((cur_gamma & 0xff00)>>8);
                        EP0BUF[1]= (uint8_t)(cur_gamma & 0x00ff);
                        apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                        if (apiRetStatus != CY_U3P_SUCCESS)
                        {
                            /* Error handling */
                            CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                        }
                    }
                }
            }

            /* Check for UVC SET_CUR request event */
            if (flag & CY_FX_UVC_SET_CUR_EVENT)
            {
                CyU3PDebugPrint (4, "It's SET_CUR - video control request. Flag = 0x%x\n", flag);
                //APTINA: Is it a videostreaming request?
                if (flag & CY_FX_UVC_VS_EVENT)
                {
                    /* Get the UVC Probe/Commit Control data from EP0 */
                    /* Host sends 26 bytes of data on EP0, but in this example, data stored in memory glCommitCtrl is used directly. */
                    /* Commit control data is not interpreted */
                    apiRetStatus = CyU3PUsbGetEP0Data(CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED, glCommitCtrl, &readCount);
                    if (apiRetStatus != CY_U3P_SUCCESS)
                    {
                        /* Error handling */
                        CyU3PDebugPrint (4, "USB EP0 Receive Data Failed, Error Code = %d\n",apiRetStatus);
                    }

                    /* Check the read count */
                    /* Expecting a count of CY_FX_UVC_MAX_PROBE_SETTING bytes */
                    if (readCount != (uint16_t)CY_FX_UVC_MAX_PROBE_SETTING)
                    {
                        /* Error handling */
                        CyU3PDebugPrint (4, "Invalid number of bytes received in SET_CUR Request");
                    }
                }
                else //This is a video control request
                {
                    if (flag & CY_FX_UVC_BRIGHTNESS_CONTROL)
                    {
                        apiRetStatus = CyU3PUsbGetEP0Data(CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED, EP0BUF, &readCount);
                        if (apiRetStatus != CY_U3P_SUCCESS)
                        {
                            /* Error handling */
                            CyU3PDebugPrint (4, "USB EP0 Receive Data Failed, Error Code = %d\n",apiRetStatus);
                        }
                        cur_brightness = (uint16_t) EP0BUF[1];
                        SensorWrite2B(0xCC, 0x0A, 0x00, EP0BUF[1]);
                    }
                    if (flag & CY_FX_UVC_SATURATION_CONTROL)
                    {
                        apiRetStatus = CyU3PUsbGetEP0Data(CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED, EP0BUF, &readCount);
                        if (apiRetStatus != CY_U3P_SUCCESS)
                        {
                            /* Error handling */
                            CyU3PDebugPrint (4, "USB EP0 Receive Data Failed, Error Code = %d\n",apiRetStatus);
                        }
                        cur_saturation = (((uint16_t) EP0BUF[0])<<8) | ((uint16_t) EP0BUF[1]);
                        SensorWrite2B(0xCC, 0x12, EP0BUF[0], EP0BUF[1]);
                    }
                    if (flag & CY_FX_UVC_CONTRAST_CONTROL)
                    {
                        apiRetStatus = CyU3PUsbGetEP0Data(CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED, EP0BUF, &readCount);
                        if (apiRetStatus != CY_U3P_SUCCESS)
                        {
                            /* Error handling */
                            CyU3PDebugPrint (4, "USB EP0 Receive Data Failed, Error Code = %d\n",apiRetStatus);
                        }
                        cur_contrast = (uint16_t) EP0BUF[1];
                        SensorWrite2B(0xCC, 0x0C, 0x00, EP0BUF[1]);
                    }
                    if (flag & CY_FX_UVC_GAMMA_CONTROL)
                    {
                        apiRetStatus = CyU3PUsbGetEP0Data(CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED, EP0BUF, &readCount);
                        if (apiRetStatus != CY_U3P_SUCCESS)
                        {
                            /* Error handling */
                            CyU3PDebugPrint (4, "USB EP0 Receive Data Failed, Error Code = %d\n",apiRetStatus);
                        }
                        cur_gamma = (((uint16_t) EP0BUF[0])<<8) | ((uint16_t) EP0BUF[1]);
                        SensorWrite2B(0xC9, 0x40, EP0BUF[0], EP0BUF[1]);
                    }
                }
            }

        }
        if (flag & CY_FX_UVC_GET_MIN_EVENT)
        {
            CyU3PDebugPrint (4, "It's GET_MIN - video control request. Flag = 0x%x\n", flag);
            if (flag & CY_FX_UVC_BRIGHTNESS_CONTROL)
            {
                EP0BUF[0]= (uint8_t)0x00;
                EP0BUF[1]= (uint8_t)0x00;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_SATURATION_CONTROL)
            {
                EP0BUF[0]= (uint8_t)0x00;
                EP0BUF[1]= (uint8_t)0x00;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_CONTRAST_CONTROL)
            {
                EP0BUF[0]= (uint8_t)0x00;
                EP0BUF[1]= (uint8_t)0x10;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_GAMMA_CONTROL)
            {
                EP0BUF[0]= (uint8_t)0x00;
                EP0BUF[1]= (uint8_t)0x64;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }
            }
        }
        if (flag & CY_FX_UVC_GET_MAX_EVENT)
        {
            CyU3PDebugPrint (4, "It's GET_MAX - video control request. Flag = 0x%x\n", flag);
            if (flag & CY_FX_UVC_BRIGHTNESS_CONTROL)
            {
                EP0BUF[0]= (uint8_t)0x00;
                EP0BUF[1]= (uint8_t)0xFF;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_SATURATION_CONTROL)
            {
                EP0BUF[0]= (uint8_t)0x01;
                EP0BUF[1]= (uint8_t)0x00;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_CONTRAST_CONTROL)
            {
                EP0BUF[0]= (uint8_t)0x00;
                EP0BUF[1]= (uint8_t)0x40;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_GAMMA_CONTROL)
            {
                EP0BUF[0]= (uint8_t)0x01;
                EP0BUF[1]= (uint8_t)0x2C;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }
            }
        }
        if (flag & CY_FX_UVC_GET_DEF_EVENT)
        {
            CyU3PDebugPrint (4, "It's GET_DEF - video control request. Flag = 0x%x\n", flag);
            if (flag & CY_FX_UVC_BRIGHTNESS_CONTROL)
            {
                EP0BUF[0]= (uint8_t)((def_brightness & 0xff00)>>8);
                EP0BUF[1]= (uint8_t)(def_brightness & 0x00ff);
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_SATURATION_CONTROL)
            {
                EP0BUF[0]= (uint8_t)((def_saturation & 0xff00)>>8);
                EP0BUF[1]= (uint8_t)(def_saturation & 0x00ff);
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_CONTRAST_CONTROL)
            {
                EP0BUF[0]= (uint8_t)((def_contrast & 0xff00)>>8);
                EP0BUF[1]= (uint8_t)(def_contrast & 0x00ff);
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_GAMMA_CONTROL)
            {
                EP0BUF[0]= (uint8_t)((def_gamma & 0xff00)>>8);
                EP0BUF[1]= (uint8_t)(def_gamma & 0x00ff);
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }
            }
        }
        if (flag & CY_FX_UVC_GET_RES_EVENT)
        {
            CyU3PDebugPrint (4, "It's GET_RES - video control request. Flag = 0x%x\n", flag);
            if (flag & CY_FX_UVC_BRIGHTNESS_CONTROL)
            {
                EP0BUF[0]= 0x00;
                EP0BUF[1]= 0x01;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_SATURATION_CONTROL)
            {
                EP0BUF[0]= 0x00;
                EP0BUF[1]= 0x01;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_CONTRAST_CONTROL)
            {
                EP0BUF[0]= 0x00;
                EP0BUF[1]= 0x01;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }

            }
            if (flag & CY_FX_UVC_GAMMA_CONTROL)
            {
                EP0BUF[0]= 0x00;
                EP0BUF[1]= 0x01;
                apiRetStatus = CyU3PUsbSendEP0Data(2, (uint8_t *)EP0BUF);
                if (apiRetStatus != CY_U3P_SUCCESS)
                {
                    /* Error handling */
                    CyU3PDebugPrint (4, "USB EP0 Send Data Failed, Error Code = %d\n",apiRetStatus);
                }
            }
        }
        /* Relinguish the thread */
        CyU3PThreadRelinquish ();
    }
}
 

   

 

   

Thanks,

   

Jim

0 Likes
2 Replies
Anonymous
Not applicable

Hi Jiming,

   

This needs some digging into. Please create a tech support case (MyAccount -> MyCases) so that one of our engineers can help you with this.

   

Regards,

   

Anand

0 Likes
Anonymous
Not applicable

 Hi Jim,

   

You have to modify the UVC descriptor also.

   

Or the page will not work.

0 Likes