• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Embedded Software » Linux » Linux forum » Bug in vpfe_capture.c vpfe_config_image_format
Share
Linux
  • Forum
Options
  • Subscribe via RSS

Bug in vpfe_capture.c vpfe_config_image_format

Bug in vpfe_capture.c vpfe_config_image_format

This question is not answered
Matthew Schuckmann
Posted by Matthew Schuckmann
on Apr 16 2012 16:21 PM
Intellectual270 points

I'm working through the vpfe_capture.c driver code and the mt90p031 driver code in the hopes of understanding it so I can implement my own sub device driver for an imager. I'm using the dvsk-4_02_00_06 with the RidgeRun SDK. 

I noticed that there is some faulty logic in vpfe_config_image_format() specifically when the sub device doesn't support the g_fmt ioctl (the case for the mt9p031 driver).

The function sets up some defaults for in the vpfe_dev.fmt struct then attempts to get the actual format from the sub device in a temporary structure sd_fmt. 
If the g_fmt call fails with ENOICTLCMD (i.e. the sub device doesn't implement it) the function goes ahead and overwrites the defaults with the crap values in the temporary sd_fmt and things are likely to fail further on.

I think  the code following code: 

	if (ret && ret != -ENOIOCTLCMD) {
v4l2_err(&vpfe_dev->v4l2_dev,
"error in getting g_fmt from sub device\n");
return ret;
}
vpfe_dev->fmt = sd_fmt;
Should be changed to 
	if (ret && ret != -ENOIOCTLCMD) {
v4l2_err(&vpfe_dev->v4l2_dev,
"error in getting g_fmt from sub device\n");
return ret;
}
else if( !ret )
	vpfe_dev->fmt = sd_fmt;

So we only fail on a true error and only overwrite the defaults g_fmt really succeeds. 
I'm brand new to working with Linux driver code so don't know the proper way to go about submitting this as a bug and a corresponding fix so please advise me on what to do. 
Thanks, 
Matt Schuckmann
DVSDK DM368 V4L2 video capture driver Linux Drivers Kernel VPFE Linux driver DVSDK 4.00
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Matthew Schuckmann
    Posted by Matthew Schuckmann
    on Apr 16 2012 18:20 PM
    Intellectual270 points

    After digging even further I'm even more confused the comment on line 530 of vpfe_capture.c states "if sub device supports g_fmt, override the defaults" 

    However v4l2_device_call_until_err() doesn't tell you if the sub_dev doesn't implement a ioctl. 

    The macro __v4l2_device_call_subdevs_until_err() (which is what v4l2_device_call_until_err() is based on) returns 0 if the sub device for the group id is not found or the callback for the operation is not set in the sub device operations structure is not set or ENOIOCTLCMD is returned by the callback, or if the callback returns 0, so how are we to know if the sub device supports the operation? 

    This is completely baffling to me, I must be missing something here, could somebody please help me out. If there is another forum or list I should be posting to please tell me.

    Thanks

    Matt Schuckmann

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Vaibhav Hiremath
    Posted by Vaibhav Hiremath
    on Apr 17 2012 14:33 PM
    Expert8160 points

    I don't understand, what is an issue or confusion here. The code snippet clearly means,

    Any error except -ENOIOCTLCMD will exit the loop with that error. If no errors (except -ENOIOCTLCMD) occured, then 0 is returned.

    Thanks,

    Vaibhav

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Matthew Schuckmann
    Posted by Matthew Schuckmann
    on Apr 17 2012 15:04 PM
    Intellectual270 points

    Thanks for responding, I'm new to this kernel driver code stuff so bear with me.

    It seems that if a sub device doesn't implement a function you should be able to tell the difference between that and success, it simply baffles the mind considering if success is returned then something should have been done and it should be safe for one to do something with the results (in this case the sd_fmt structure should be filled in) and it's not. 

    The the logic and comments in vpfe_capture.c vpfe_config_image_format() suggest that the code will be able to tell if the device supports the g_fmt function and it simply can't, in fact the v4l2_device_call_until_err() macro can never return -ENOIOCTLCMD so this suggests that whomever wrote vpfe_capture_image_format() didn't understand what they were doing. 

    Further more the way the vpfe_config_image_format() is written after the attempt to call g_fmt silently fails  (with a sub device like mt9p031) the function assumes it's OK to use the sd_fmt structure and that not the case, it's uninitialized and  full of crap. 

    static int vpfe_config_image_format(struct vpfe_device *vpfe_dev,
    const v4l2_std_id *std_id)
    {
    ....
    /* if sub device supports g_fmt, override the defaults */
    ret = v4l2_device_call_until_err(&vpfe_dev->v4l2_dev,
    sdinfo->grp_id, video, g_fmt, &sd_fmt);


    if (ret && ret != -ENOIOCTLCMD) {
    v4l2_err(&vpfe_dev->v4l2_dev,
    "error in getting g_fmt from sub device\n");
    return ret;
    }
    vpfe_dev->fmt = sd_fmt;
    ....
    }
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use