summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* media: tvp5150: make debug output more readablemfe/media/i2c/tvp5150.10Marco Felsch2019-08-291-3/+6
| | | | | | | | | | | | | The debug output for tvp5150_selmux() isn't really intuitive. Register values are printed decimal formatted and the input/output driver states are printed as enum. Even more the "normal" output enum mapps to zero so a active output will printing output=0 and a inactive output=1. Change this by brinting the register values hex formatted and the states as more readable string. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
* media: tvp5150: add support to limit sdtv standardsMarco Felsch2019-08-291-2/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tvp5150 accepts NTSC(M,J,4.43), PAL (B,D,G,H,I,M,N) and SECAM video data and is able to auto-detect the input signal. The auto-detection does not work if the connector does not receive an input signal and the tvp5150 might not be configured correctly. This misconfiguration leads into wrong decoded video streams if the tvp5150 gets powered on before the video signal is present. Limit the supported sdtv standards according to the actual selected connector to avoid a misconfiguration. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> --- [1] https://patchwork.kernel.org/cover/10794703/ v8: - adapt commit message - fix rebasing issue - apdapt to new v4l2_fwnode_connector_analog naming - fix cur_connector update during tvp5150_link_setup() -> Only update if we have of-connectors. - fix supported_stds detection during tvp5150_s_std() -> use connectors_num to detect of-connectors presence v5: - probe() initialize supported tv-norms according the given connectors if they are available. - check if media-controller is used. Don't limit the norm if it isn't used. - add more logic to be smarter during connector changing so it is intuitiver for the user space. v2-v4: - nothing since the patch was squashed from series [1] into this series.
* media: dt-bindings: tvp5150: add optional sdtv standards documentationMarco Felsch2019-08-291-0/+10
| | | | | | | | | | | | | Document the optional binding to limit the possible sdtv standards on the input connectors. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Rob Herring <robh@kernel.org> v8: - adapt to new sdtv-standards - adapt commit message - fix missing include within example code
* media: dt-bindings: tvp5150: cleanup bindings stlyeMarco Felsch2019-08-291-13/+17
| | | | | | | | | | Use underlines to highlight optional and required properties. This is quite common for all bindings. Align descriptions and start sentence with uppercase letter. Also reword the usage of the required endpoint properties for the output port in case BT.656 should be used. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Rob Herring <robh@kernel.org>
* media: tvp5150: add s_power callbackMarco Felsch2019-08-291-6/+17
| | | | | | | | | Don't en-/disable the interrupts during s_stream because someone can disable the stream but wants to get informed if the stream is locked again. So keep the interrupts enabled the whole time the pipeline is opened. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
* media: tvp5150: initialize subdev before parsing device treeMichael Tretter2019-08-291-4/+3
| | | | | | | | | | | There are several debug prints in the tvp5150_parse_dt() function, which do not print the prefix, because the v4l2_subdev is not initialized, yet. Initialize the v4l2_subdev before parsing the device tree to fix the debug messages. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
* media: tvp5150: add FORMAT_TRY support for get/set selection handlersMarco Felsch2019-08-291-32/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 10d5509c8d50 ("[media] v4l2: remove g/s_crop from video ops") the 'which' field for set/get_selection must be FORMAT_ACTIVE. There is no way to try different selections. The patch adds a helper function to select the correct selection memory space (sub-device file handle or driver state) which will be set/returned. The selection rectangle is updated if the format is FORMAT_ACTIVE and the rectangle position and/or size differs from the current set rectangle. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> --- Changelog: v10: - __tvp5150_get_pad_crop: drop confusing fall-through - set_selection: fix FORMAT_TRY handling if CONFIG_VIDEO_V4L2_SUBDEV_API is disabled. Adapt sel->r and return 0. v8: - adapt commit message - remove wrong FORMAT_TRY handling for tvp5150_fill_fmt() handling - return 0 during set_selection if FORMAT_TRY was requested and CONFIG_VIDEO_V4L2_SUBDEV_API is disabled - return -EINVAL during get_selection if FORMAT_TRY was requested and CONFIG_VIDEO_V4L2_SUBDEV_API is disabled v7: - __tvp5150_get_pad_crop(): return error on default case - simplify __tvp5150_get_pad_crop() error handling - tvp5150_set_selection() squash __tvp5150_set_selection() execution conditions v6: nothing v5: - handle stub for v4l2_subdev_get_try_crop() internal since commit ("media: v4l2-subdev: add stubs for v4l2_subdev_get_try_*") isn't anymore part of this series. - add error handling of __tvp5150_get_pad_crop() v4: - fix merge conflict due to rebase on top of media-tree/master - __tvp5150_get_pad_crop(): cosmetic alignment fixes
* media: tvp5150: fix set_selection rectangle handlingMarco Felsch2019-08-291-16/+16
| | | | | | | | | | | | | | | Currently a local copy of sel->r is made and adapted to the hardware constraints. After the adaption the value is applied to the hardware but the driver forgot to reflect the adapted value to the user space. Drop the local copy and work directly on the requested rectangle instead to fix this. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> --- v10: - new patch
* media: dt-bindings: tvp5150: Add input port connectors DT bindingsMarco Felsch2019-08-291-7/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The TVP5150/1 decoders support different video input sources to their AIP1A/B pins. Possible configurations are as follows: - Analog Composite signal connected to AIP1A. - Analog Composite signal connected to AIP1B. - Analog S-Video Y (luminance) and C (chrominance) signals connected to AIP1A and AIP1B respectively. This patch extends the device tree bindings documentation to describe how the input connectors for these devices should be defined in a DT. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Rob Herring <robh@kernel.org> --- Changelog: v7: Hi Rob, I droped your r b tag because I changed the bindings in this patch version. Please can you have a look on it again? - fix missing AIP1B svideo connection (description and examples) v3: - remove examples for one and two inputs - replace space by tabs v2: - adapt port layout in accordance with https://www.spinics.net/lists/linux-media/msg138546.html with the svideo-connector deviation (use only one endpoint)
* media: tvp5150: add input source selection of_graph supportMarco Felsch2019-08-291-30/+348
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the of_graph support to describe the tvp input connections. Physical the TVP5150 has three ports: AIP1A, AIP1B and YOUT. As result of discussion [1],[2] the device-tree maps these ports 1:1. Look at the Documentation for more information. Since the TVP5150 is a converter/bridge the device-tree must contain at least 1-input and 1-output port. The mc-connectors and mc-links are only created if the device-tree contains the corresponding connector nodes. If more than one connector is available the media_entity_operations.link_setup() callback ensures that only one connector is active. [1] https://www.spinics.net/lists/linux-media/msg138545.html [2] https://www.spinics.net/lists/linux-media/msg138546.html Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> --- Changelog: [1] https://patchwork.kernel.org/cover/10794703/ [2] https://patchwork.kernel.org/cover/10786553/ v8: - fix rebasing issue - fix error handling during tvp5150_registered() - adapt to new v4l2_connector_type enum v7: - don't init enum tvp5150_pads with TVP5150_COMPOSITE0 functionality - break some 80 character limitation to improve readability - fix comment style -> always start with capital letters and end with dot - fix some minor style issues - fix tvp5150_registered error handling - simplify tvp5150_mc_init - make connectors static -> since now only three connectors are possible (as described in DT) -> drop tvp5150.endpoints storage -> squash tvp5150_parse_dt and tvp5150_add_of_connectors - improve tvp5150_parse_dt: -> make parsing stricter and fix not detected missconfigured dt-data -> svideo must be connected now to port@[0,1]/endpoint@1 v6: - fix misspelled comments - use 'unsigned int' where it's possible - cleanup ifdef part-2: * tvp5150_mc_init, tvp5150_add_of_connectors: add surrounding CONFIG_MEDIA_CONTROLLER if def and stubs to improve quality - tvp5150_mc_init: uniform interface, use 'struct tvp5150' since all internal function do this. - tvp5150_add_of_connectors: call within probe() to make it cleaner - tvp5150_parse_dt: move local loop vars within the loop. v5: - Fixing build deps: - tvp5150_mc_init: fix CONFIG_MEDIA_CONTROLLER deps - struct tvp5150: drop CONFIG_MEDIA_CONTROLLER conditional property includes. This leads into to complex deps for futher development. - tvp5150_dt_cleanup: enable function only if CONFIG_OF is enabled - tvp5150_parse_dt: enable function only if CONFIG_OF is enabled - tvp5150_probe: call tvp5150_dt_cleanup only if CONFIG_OF is enabled - Simplify link_setup routine: - use generic connector parsing since both series [1,2] are squashed into one - struct tvp5150: drop pads_state and modify_second_link property due to link_setup() rework. - tvp5150_link_setup: add more comments - tvp5150_link_setup: simply the link setup routine a lot. Edit the 2nd link directly within the driver instead of a recursive media-framework call (__media_entity_setup_link). This improves the readability and shrinks the driver code. - tvp5150_link_setup: disable all active links in case user switches connectors without disable it first. - tvp5150_registered: simplify default link enable path due to link_setup() rework. - General cleanups - tvp5150_parse_dt: drop unecessary test - tvp5150_parse_dt: add err message due to misconfiguration - tvp5150_parse_dt: make use of V4L2_MBUS_UNKNOWN definition - s/dev_dbg/dev_dbg_lvl v4: - rebase on top of media_tree/master, fix merge conflict due to commit 60359a28d592 ("media: v4l: fwnode: Initialise the V4L2 fwnode endpoints to zero") v3: - probe(): s/err/err_free_v4l2_ctrls - drop MC dependency for tvp5150_pads v2: - adapt commit message - unify ifdef switches - rename tvp5150_valid_input -> tvp5150_of_valid_input, to be more precise - mc: use 2-input and 1-output pad - mc: link svideo connector to both input pads - mc: enable/disable svideo links in one go - mc: change link_setup() behaviour, switch the input src don't require a explicite disable before. - mc: rename 'local' media_pad param to tvp5150_pad to avoid confusion - mc: enable link to the first available connector and set the corresponding tvp5150 input src per default during registered() - mc/of: factor out oftree connector allocation - of: drop svideo dt port - of: move svideo connector to port@0/endpoint@1 - of: require at least 1-in and 1-out endpoint
* partial revert of "[media] tvp5150: add HW input connectors support"Javier Martinez Canillas2019-08-292-147/+0
| | | | | | | | | | | | | | | | | | | | | | | Commit f7b4b54e6364 ("[media] tvp5150: add HW input connectors support") added input signals support for the tvp5150, but the approach was found to be incorrect so the corresponding DT binding commit 82c2ffeb217a ("[media] tvp5150: document input connectors DT bindings") was reverted. This left the driver with an undocumented (and wrong) DT parsing logic, so lets get rid of this code as well until the input connectors support is implemented properly. It's a partial revert due other patches added on top of mentioned commit not allowing the commit to be reverted cleanly anymore. But all the code related to the DT parsing logic and input entities creation are removed. Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> [m.felsch@pengutronix.de: rm TVP5150_INPUT_NUM define] Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Acked-by: Rob Herring <robh@kernel.org>
* media: v4l2-fwnode: add initial connector parsing supportMarco Felsch2019-08-292-0/+167
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The patch adds the initial connector parsing code, so we can move from a driver specific parsing code to a generic one. Currently only the generic fields and the analog-connector specific fields are parsed. Parsing the other connector specific fields can be added by a simple callbacks. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> --- [1] https://patchwork.kernel.org/cover/10794703/ v10: - drop V4L2_CONN_HDMI support - adapt pr_err msg to reflect new state (-> connector is unkown) v9: - Fix leading semicolon found by kbuild semicolon.cocci v8: - V4L2_CON_* -> V4L2_CONN_* - tvnorms -> sdtv-standards - adapt to new v4l2_fwnode_connector_analog member - return error in case of V4L2_CONN_HDMI v7: @Jacopo: I dropped your r b tag becuase of the amount of changes I made.. - drop unnecessary comments - fix commet style - s/v4l2_fwnode_connector_conv.name/v4l2_fwnode_connector_conv.compatible/ - make label size variable and drop V4L2_CONNECTOR_MAX_LABEL usage - do not assign a default label in case of no label was specified - remove useless /* fall through */ comments - add support for N connector links - rename local variables to be more meaningful - adjust kernedoc - add v4l2_fwnode_connector_free() - improve error handling (use different error values) - make use of pr_warn_once() v6: - use unsigned count var - fix comment and style issues - place '/* fall through */' to correct places - fix error handling and cleanup by releasing fwnode - drop vga and dvi parsing support as those connectors are rarely used these days v5: - s/strlcpy/strscpy/ v2-v4: - nothing since the patch was squashed from series [1] into this series.
* media: v4l2-fwnode: add v4l2_fwnode_connectorMarco Felsch2019-08-291-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently every driver needs to parse the connector endpoints by it self. This is the initial work to make this generic. A generic connector has common members and connector specific members. The common members are: - type - label (optional) - links - nr_of_links The specific members are stored within a union, since only one of them can be available at the time. Since this is the initial support the patch adds only the analog-connector specific ones. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> --- [1] https://patchwork.kernel.org/cover/10794703/ v10: - drop unused V4L2_CONN_HDMI support v8: - rename CON -> CONN - supported_tvnorms_stds -> sdtv_stds and adapt description v7: - fix spelling issues - constify label - support variable label size - replace single remote_port/id members by links member of variable size - squash v4l2-connector into v4l2-fwnode @Jacopo: I dropped your r b tag because I changed the port/id logic. v6: - fix some spelling and style issues - rm unnecessary comments - drop vga and dvi connector - fix misspelt connector v2-v4: - nothing since the patch was squashed from series [1] into this series.
* dt-bindings: connector: analog: add sdtv standards propertyMarco Felsch2019-08-293-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some connectors no matter if in- or output supports only a limited range of sdtv standards. It doesn't matter if the hardware behind that connector supports more than the listed formats since the users are restriced by a label e.g. to plug only a camera into this connector which uses the PAL format. This patch adds the capability to describe such limitation within the firmware. There are no format restrictions if the property isn't present, so it's completely backward compatible. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Reviewed-by: Rob Herring <robh@kernel.org> --- [1] https://patchwork.kernel.org/cover/10794703/ v10: - fix typo s/TV_STD_*/SDTV_STD_*/ v8: Hi Rob, I dropped your r b tag becuase of the changes I made in this version. Please can you have look on it again? Luckily this would be the last time ;-) - move definition to include/dt-bindings/display - rename tvnorms.h to sdtv-standards.h - TVORMS_* -> SDTV_STD_* - add sync comments - adapt commit message - fix bindings documentation v7: I kept Robs r b tag because I only changed the example and extended TVNORM_* macros. - fix some style issues - add TVNORM_NTSC, TVNORM_525_60 and TVNORM_625_50 v6: - tvnorms.h: use tabs instead of spaces - tvnorms.h: add TVNORM_PAL and TVNORM_SECAM - tvnorms.h: drop rarely used TVNORM_ATSC_* norms v2-v4: - nothing since the patch was squashed from series [1] into this series.
* media: imx: remove unused including <linux/version.h>YueHaibing2019-08-291-1/+0
| | | | | | | | Remove including <linux/version.h> that don't need it. Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: stm32-dcmi: Delete an unnecessary of_node_put() call in dcmi_probe()Markus Elfring2019-08-291-1/+0
| | | | | | | | | | | | | A null pointer would be passed to a call of the function “of_node_put” immediately after a call of the function “of_graph_get_next_endpoint” failed at one place. Remove this superfluous function call. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: pvrusb2: qctrl.flag will be uninitlaized if cx2341x_ctrl_query() ↵Yizhuo2019-08-291-1/+1
| | | | | | | | | | | | | | returns error code Inside function ctrl_cx2341x_getv4lflags(), qctrl.flag will be uninitlaized if cx2341x_ctrl_query() returns -EINVAL. However, it will be used in the later if statement, which is potentially unsafe. Signed-off-by: Yizhuo <yzhai003@ucr.edu> Acked-by: Mike Isely <isely@pobox.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: em28xx: Fix exception handling in em28xx_alloc_urbs()Markus Elfring2019-08-291-1/+1
| | | | | | | | | | | | | | A null pointer would be passed to a call of the function "kfree" directly after a call of the function "kcalloc" failed at one place. Pass the data structure member "urb" instead for which memory was allocated before (so that this resource will be properly cleaned up). This issue was detected by using the Coccinelle software. Fixes: d571b592c6206d33731f41aa710fa0f69ac8611b ("media: em28xx: don't use coherent buffer for DMA transfers") Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: don't do a 31 bit shift on a signed intMauro Carvalho Chehab2019-08-2619-38/+38
| | | | | | | | | | | | | | | | On 32-bits archs, a signed integer has 31 bits plus on extra bit for signal. Due to that, touching the 32th bit with something like: int bar = 1 << 31; has an undefined behavior in C on 32 bit architectures, as it touches the signal bit. This is warned by cppcheck. Instead, force the numbers to be unsigned, in order to solve this issue. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: use the BIT() macroMauro Carvalho Chehab2019-08-2616-1002/+1014
| | | | | | | | | | | | | | | | | | | | | | As warned by cppcheck: [drivers/media/dvb-frontends/cx24123.c:434]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour [drivers/media/pci/bt8xx/bttv-input.c:87]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour [drivers/media/pci/bt8xx/bttv-input.c:98]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour ... [drivers/media/v4l2-core/v4l2-ioctl.c:1391]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour There are lots of places where we're doing 1 << 31. That's bad, as, depending on the architecture, this has an undefined behavior. The BIT() macro is already prepared to handle this, so, let's just switch all "1 << number" macros by BIT(number) at the header files with has 1 << 31. Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> # exynos4-is and s3c-camif Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> # omap3isp, vsp1, xilinx, wl128x and ipu3 Reviewed-by: Benoit Parrot <bparrot@ti.com> # am437x and ti-vpe Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: ov9650: add a sanity checkMauro Carvalho Chehab2019-08-261-0/+5
| | | | | | | | | | | | | | | | | | | As pointed by cppcheck: [drivers/media/i2c/ov9650.c:706]: (error) Shifting by a negative value is undefined behaviour [drivers/media/i2c/ov9650.c:707]: (error) Shifting by a negative value is undefined behaviour [drivers/media/i2c/ov9650.c:721]: (error) Shifting by a negative value is undefined behaviour Prevent mangling with gains with invalid values. As pointed by Sylvester, this should never happen in practice, as min value of V4L2_CID_GAIN control is 16 (gain is always >= 16 and m is always >= 0), but it is too hard for a static analyzer to get this, as the logic with validates control min/max is elsewhere inside V4L2 core. Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: aspeed-video: address a protential usage of an unitialized varMauro Carvalho Chehab2019-08-261-2/+3
| | | | | | | | | | | | | | | | | | | | While this might not occur in practice, if the device is doing the right thing, it would be teoretically be possible to have both hsync_counter and vsync_counter negatives. If this ever happen, ctrl will be undefined, but the driver will still call: aspeed_video_update(video, VE_CTRL, 0, ctrl); Change the code to prevent this to happen. This was warned by cppcheck: [drivers/media/platform/aspeed-video.c:653]: (error) Uninitialized variable: ctrl Reviewed-by: Eddie James <eajames@linux.ibm.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: vicodec: make life easier for static analyzersMauro Carvalho Chehab2019-08-261-4/+7
| | | | | | | | | | | cppcheck incorrectly produces an error here: [drivers/media/platform/vicodec/vicodec-core.c:1677]: (error) Pointer addition with NULL pointer. While this is actually a false positive, it doesn't hurt to reorder the checks to make the code simpler, handling first the error patch, where no color or alpha components are there. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: remove include stdarg.h from some driversMauro Carvalho Chehab2019-08-264-5/+1
| | | | | | | | | It doesn't make any sense to have gcc's stdarg.h included inside the Linux Kernel. Get rid of those includes. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* v4l2-core: fix coding style for the two new c filesMauro Carvalho Chehab2019-08-262-33/+54
| | | | | | | | As I2C and SPI parts of the V4L2 core got split, let's take the chance and solve the CodingStyle issues there, as reported by checkpatch --strict. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: v4l2-core: Remove BUG() from i2c and spi helpersEzequiel Garcia2019-08-262-3/+4
| | | | | | | | | | | | | | | | Currently, the i2c and spi subdev creation helpers are calling BUG() when passed a NULL v4l2_device parameter. This makes little sense; simply returning NULL seems more sensible. These two helpers may already return NULL on error, so callers should already be checking for this, or at least be prepared for a NULL result. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: v4l2-core: introduce a helper to unregister a i2c subdevEzequiel Garcia2019-08-263-23/+32
| | | | | | | | | | Introduce a new video4linux2 i2c helper, to unregister a subdev. This allows to get rid of yet another ifdef. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> [hverkuil-cisco@xs4all.nl: fix checkpatch warning] Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: v4l2-core: introduce a helper to unregister a spi subdevEzequiel Garcia2019-08-263-12/+19
| | | | | | | | | Introduce a new video4linux2 spi helper, to unregister a subdev. This allows to get rid of some more ifdefs. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: v4l2-core: move i2c helpers out of v4l2-common.cEzequiel Garcia2019-08-265-182/+229
| | | | | | | | | | | | | Separate the i2c helpers to v4l2-i2c.c, in order to get rid of the ifdefery. No functional changes intended, this is just a cosmetic change to organize the code better. Given I2C is a tristate symbol, a hidden boolean symbol is introduced, to make the conditional build easier. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: v4l2-core: move spi helpers out of v4l2-common.cEzequiel Garcia2019-08-264-67/+82
| | | | | | | | | | Separate the spi helpers to v4l2-spi.c, in order to get rid of the ifdefery. No functional changes intended, this is just a cosmetic change to organize the code better. Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: v4l2-core: Module re-organizationEzequiel Garcia2019-08-263-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | videodev.ko and v4l2-common.ko driver are built under the same conditions. Therefore, it doesn't make much sense to split them in two different modules. Splitting v4l2-common to its own driver was done many years ago: commit a9254475bbfbed5f0596d952c6a3c9806e19dd0b Author: Mauro Carvalho Chehab <mchehab@infradead.org> Date: Tue Jan 29 18:32:35 2008 -0300 V4L/DVB (7115): Fix bug #9833: regression when compiling V4L without I2C Back then, the subsystem organization was different and the module split was needed. However, with the current organization, there is no issue compiling V4L2 with I2C as y/m/n. This commit makes v4l2-common part of our V4L2 core driver (videodev.ko). Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: usbvision: Remove dead codeSouptick Joarder2019-08-261-10/+0
| | | | | | | | | | These codes are commented since v4.2-rc1. If there is no plan to enable the #else part in future, these can be removed forever. Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: aspeed: fix an incorrect return code on buffer allocation failureJae Hyun Yoo2019-08-261-0/+1
| | | | | | | | | | It returns '0' even when a failure happens on jpeg buffer allocation so this commit fixes the issue. Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> Reviewed-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: hantro: Enable VP8 decoding on RK3328Jonas Karlman2019-08-261-1/+1
| | | | | | | | | RK3328 SoC has the same decoder IP block as RK3399, lets enable VP8 decoding on RK3328. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: saa7134: fix terminology around saa7134_i2c_eeprom_md7134_gate()Maciej S. Szmigiero2019-08-261-4/+8
| | | | | | | | | | | saa7134_i2c_eeprom_md7134_gate() function and the associated comment uses an inverted i2c gate open / closed terminology. Let's fix this. Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> [hverkuil-cisco@xs4all.nl: fix alignment checkpatch warning] Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: saa7134: keep demod i2c gate closed on Medion 7134Maciej S. Szmigiero2019-08-261-0/+14
| | | | | | | | | | | | | | | | | | | | Medion 7134 has two i2c eeproms on the same i2c bus sharing the same bus addresses: the first one for SAA7134 chip config and the second one behind TDA10046 DVB-T demod chip i2c gate storing its firmware. The TV tuner on this board is not behind this i2c gate. Due to the bus conflict described above, the card PCI SVID / SSID sometimes gets garbled after a reboot, which makes it necessary to specify the card model manually as an insmod option in order for it to be detected reliably. To avoid this, let's just leave the gate permanently closed so the eeprom chips won't clash. The demod firmware load is done with its i2c gate closed anyway so it is not affected by this change. Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: i2c: adv7842: drop check because i2c_unregister_device() is NULL safeWolfram Sang2019-08-261-22/+11
| | | | | | | | | No need to check the argument of i2c_unregister_device() because the function itself does it. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: i2c: adv7511-v4l2: drop check because i2c_unregister_device() is NULL ↵Wolfram Sang2019-08-261-4/+2
| | | | | | | | | | | safe No need to check the argument of i2c_unregister_device() because the function itself does it. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: hdpvr: remove redundant assignment to retvalColin Ian King2019-08-261-5/+1
| | | | | | | | | | | | | Variable retval is initialized to a value that is never read so this assignment is redundant. Clean up the code by removing retval completely and just return the error return from the call to i2c_add_adapter. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: sn9c20x: Add MSI MS-1039 laptop to flip_dmi_tableHans de Goede2019-08-261-0/+7
| | | | | | | | | | | | | Like a bunch of other MSI laptops the MS-1039 uses a 0c45:627b SN9C201 + OV7660 webcam which is mounted upside down. Add it to the sn9c20x flip_dmi_table to deal with this. Cc: stable@vger.kernel.org Reported-by: Rui Salvaterra <rsalvaterra@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: ti-vpe: Add cleanup in vpdma_list_cleanup()Wenwen Wang2019-08-261-4/+6
| | | | | | | | | | If an error occurs in this function, no cleanup is executed, leading to memory/resource leaks. To fix this issue, introduce two labels to perform the cleanup work. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: fdp1: Fix a memory leak bugWenwen Wang2019-08-261-0/+1
| | | | | | | | | | | In fdp1_open(), 'ctx' is allocated through kzalloc(). However, it is not deallocated if v4l2_ctrl_new_std() fails, leading to a memory leak bug. To fix this issue, free 'ctx' before going to the 'done' label. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: saa7146: add cleanup in hexium_attach()Wenwen Wang2019-08-261-0/+3
| | | | | | | | | | If saa7146_register_device() fails, no cleanup is executed, leading to memory/resource leaks. To fix this issue, perform necessary cleanup work before returning the error. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: usb: cx231xx-417: fix a memory leak bugWenwen Wang2019-08-261-0/+1
| | | | | | | | | | In cx231xx_load_firmware(), 'p_buffer' is allocated through vmalloc() to hold the firmware. However, after the usage, it is not deallocated, leading to a memory leak bug. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: cpia2_usb: fix memory leaksWenwen Wang2019-08-261-0/+4
| | | | | | | | | | In submit_urbs(), 'cam->sbuf[i].data' is allocated through kmalloc_array(). However, it is not deallocated if the following allocation for urbs fails. To fix this issue, free 'cam->sbuf[i].data' if usb_alloc_urb() fails. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: imx: add csc/scaler mem2mem devicePhilipp Zabel2019-08-266-2/+972
| | | | | | | | | | | | | | | | | | | | | | | | Add a single imx-media mem2mem video device that uses the IPU IC PP (image converter post processing) task for scaling and colorspace conversion. On i.MX6Q/DL SoCs with two IPUs currently only the first IPU is used. The hardware only supports writing to destination buffers up to 1024x1024 pixels in a single pass, arbitrary sizes can be achieved by rendering multiple tiles per frame. [slongerbeam@gmail.com: use ipu_image_convert_adjust(), fix device_run() error handling, add missing media-device header, unregister and remove the mem2mem device in error paths in imx_media_probe_complete() and in imx_media_remove(), updated for sync subdev registration] Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Steve Longerbeam <slongerbeam@gmail.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> [hverkuil-cisco@xs4all.nl: correct two minor checkpatch issues] [hverkuil-cisco@xs4all.nl: sparse warning: make imx6_media_probe_complete static] Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: cec-notifier: clear cec_adap in cec_notifier_unregisterHans Verkuil2019-08-261-0/+2
| | | | | | | | | | | | | | | | | | | | If cec_notifier_cec_adap_unregister() is called before cec_unregister_adapter() then everything is OK (and this is the case today). But if it is the other way around, then cec_notifier_unregister() is called first, and that doesn't set n->cec_adap to NULL. So if e.g. cec_notifier_set_phys_addr() is called after cec_notifier_unregister() but before cec_unregister_adapter() then n->cec_adap points to an unregistered and likely deleted cec adapter. So just set n->cec_adap->notifier and n->cec_adap to NULL for rubustness. Eventually cec_notifier_unregister will disappear and this will be simplified substantially. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: cec-adap: return from cec_s_conn_info() if adap is invalidHans Verkuil2019-08-261-0/+3
| | | | | | | | | | | Check if cec_s_conn_info is called with a valid cec adapter, do nothing if it is invalid. This makes it possible to call this function even if CEC support is disabled in the kernel config. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: sunxi: Add A10 CSI driverMaxime Ripard2019-08-239-0/+1332
| | | | | | | | | | | | | | | The older CSI drivers have camera capture interface different from the one in the newer ones. This IP is pretty simple. Some variants (one controller out of two instances on some SoCs) have an ISP embedded, but there's no code that make use of it, so we ignored that part for now. [Sakari Ailus: Wrapped a few long lines, set mbus code using a macro.] Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
* media: sunxi: Refactor the Makefile and KconfigMaxime Ripard2019-08-234-2/+4
| | | | | | | | | | | The Makefile and Kconfig for the sun6i CSI driver are included in the main Makefile / KConfig file. Since we're going to add a new CSI driver for an older chip, and the Cedrus driver eventually, it makes more sense to put those in our directory. Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>