arm: tegra: tamonten: Name the I2C buses

Use defines for the i2c bus numbers, it make the code easier to read
and should allow for a better portability to newer Tamonten module.

Change-Id: I0d497ca60df3550c08dbe181f1ea8642afa0bb06
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/510
Reviewed-by: Soeren Grunewald <soeren.grunewald@avionic-design.de>
arm: tegra: tamonten: Add T30 support to the display setup

Fix the host1x init to also support the T30 devices.

Change-Id: Icb61a1f8ce882366531ee0cd9c12e9ac4a85b5e4
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/516
Reviewed-by: Soeren Grunewald <soeren.grunewald@avionic-design.de>
arm: tegra: tamonten: Abstract the PWM IDs

Add defines for the PWMs, again this is to allow an easier integration
with other Tamonten COM modules.

Change-Id: I3711e1c669dc2402dfaebf76c6b9a412471361f9
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/517
Reviewed-by: Soeren Grunewald <soeren.grunewald@avionic-design.de>
arm: tegra: tec-ng: Fix the license header indentation

Change-Id: I2ff9b602e5253fbaddbf41196bb44cca453013b5
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/524
Reviewed-by: Soeren Grunewald <soeren.grunewald@avionic-design.de>
arm: tegra: tamonten: Remove the unused SD power GPIO

The pin behind this GPIO is only connected to a test point (TP16) and never
controlled the SD reader power supply. Remove it to avoid any misunderstanding
regarding the SD reader powering.

Change-Id: I53b03ae937f6a41a9cd7f058e968c4d0994ff91f
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/512
Reviewed-by: Soeren Grunewald <soeren.grunewald@avionic-design.de>
arm: tegra: tec-ng: Add pcie support.

Enable the Tegra PCIe controller. This was successfully tested with the FPGA
on the TEC-NG baseboard.

Signed-off-by: Julian Scheel <julian@jusst.de>
Change-Id: Id3392318a12b2981414231f47050ff53a924e03a
Reviewed-on: http://review.adnet.avionic-design.de/482
Reviewed-by: Soeren Grunewald <soeren.grunewald@avionic-design.de>
media: tvp5150: Revert the WIP patches from r16-2

This reverts 2 WIP patches that came from the merge of r16-2 to allow
us to first apply patches from upstream.

Revert "WIP: tvp5150: disable external H/V sync"
commit d41b9de3c5b410089a525868cfd8ec25555a0b2f.

Revert "WIP: make tvp5150 driver soc_camera compatible."
commit f5e3f27584418ec7f51c4e011aa6f41017dc22c9.

Change-Id: I0d5c3eba5b47eebead06a7ef380acc2bee87b529
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/530
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] tvp5150: Add video format registers configuration values

The tvp5150 video decoder has two operation modes to configure the video
standard used.

If auto-switch mode is enable, the device can sense the signal and detect which
video standard the device is operating. Also the device can be forced to use a
user defined video standard.

Each operation mode uses a different register and the bitmask values to
represent each standard is different.

So we add video standard constants for both autoswitch and no-autoswitch mode.

Change-Id: Icd7938d8deb837272016d4ad5aeface0f7dadcfb
Signed-off-by: Javier Martinez Canillas <martinez.javier@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/531
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] tvp5150: replace video standard "magic" numbers

64933337e3cb61ca555969a35ab68b477db34ee2
[media] tvp5150: Add video format registers configuration values

Added constants for each video standard supported by TVP5150, so this patch
get rid of the magic numbers.

Change-Id: I68024c6663e5061769864fd9b1a6b3fcaafc3ca4
Signed-off-by: Javier Martinez Canillas <martinez.javier@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/532
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] media: tvp5150: Add mbus_fmt callbacks

These callbacks allow a host video driver
to poll video formats supported by tvp5150.

Change-Id: I1f5fcc78234df1bc4e4f0b8bc18ddc1602157cef
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/533
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] media: tvp5150: Add cropping support

Change-Id: I0de6a0a725baf01c5eb2336b341de0aaac340caf
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/534
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] media: tvp5150: support g_mbus_fmt callback

Change-Id: I8182dea7fc735d0e05b432a9a6bdbff1b09ebe0e
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/535
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] media: tvp5150: Fix mbus format

According to p.14 fig 3-3 of the datasheet (SLES098A)
this decoder transmits data in UYVY format.

Change-Id: Ia6f7c8c7753be002232ec40ef74192d17bfbe8d0
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/536
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] tvp5150: fix kernel crash if chip is unavailable

tvp5150 driver probe function doesn't check if the chip is present.
Thus the driver can be loaded without having a device.
This is dangerous and can cause kernel crash like this:

Kernel BUG at c03c0964 [verbose debug info unavailable]
Internal error: Oops - BUG: 0 [#1] PREEMPT ARM
Modules linked in:
CPU: 0    Tainted: G        W     (3.4.0-cm-t3730+ #2)
PC is at media_entity_create_link+0xe4/0xf4
LR is at isp_register_entities+0x228/0x2f4
pc : [<c03c0964>]    lr : [<c03f3b30>]    psr: 60000013
sp : cf02de50  ip : 00000000  fp : c079405c
r10: 00000000  r9 : 00000000  r8 : cf33c800
r7 : c0794834  r6 : 00000000  r5 : 00000000  r4 : cf365b48
r3 : 00000000  r2 : cf365b48  r1 : 00000000  r0 : cf33c800
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 10c5387d  Table: 80004019  DAC: 00000015
Process swapper (pid: 1, stack limit = 0xcf02c2f0)
Stack: (0xcf02de50 to 0xcf02e000)
de40:                                     cf360000 cf366f28 cf366218 c0794834
de60: cf365b48 00000000 cf33c800 c03f3b30 00000000 00000000 cf360890 cf3668a0
de80: 00000003 cf360000 c0785a58 00000000 cf360528 00000000 00000000 00003fff
dea0: cf360500 c03f4cdc c06cc1f4 cf360000 c0785a58 c0d27808 c07d55ec c0785a58
dec0: c031f0e0 c07d55ec c0776900 000000bb 00000000 c032040c c03203f4 c031ef0c
dee0: c0785a58 c07d55ec c0785a8c c031f0e0 c075e670 c031f0c8 cf02deb8 c0785a58
df00: c07d55ec c031f174 c07d55ec 00000000 cf02df18 c031d7a0 cf01d4a8 cf068b10
df20: 00000000 c07d55ec c07c74d0 cf34bcc0 00000000 c031ded8 c0672340 c054cd38
df40: 00000000 c07e68c0 c07d55ec 00000000 00000000 c075e670 c0776900 000000bb
df60: 00000000 c031f770 c07e68c0 00000007 c07e68c0 00000000 c075e670 c0008790
df80: 000000bb 00000006 00000006 c066e650 cf02dfa4 c07689b8 c07689b8 00000007
dfa0: c07e68c0 c073f2e8 c07689c0 000000bb 00000000 c073f2bc 00000006 00000006
dfc0: c073f2e8 00000000 c077649c c077649c c00150cc 00000013 00000000 00000000
dfe0: 00000000 c073f3cc cf02dfe8 00000000 c073f368 c00150cc 00000000 00000000
[<c03c0964>] (media_entity_create_link+0xe4/0xf4) from [<c03f3b30>] (isp_register_entities+0x228/0x2f4)
[<c03f3b30>] (isp_register_entities+0x228/0x2f4) from [<c03f4cdc>] (isp_probe+0x7ac/0x9b8)
[<c03f4cdc>] (isp_probe+0x7ac/0x9b8) from [<c032040c>] (platform_drv_probe+0x18/0x1c)
[<c032040c>] (platform_drv_probe+0x18/0x1c) from [<c031ef0c>] (really_probe+0x64/0x1d8)
[<c031ef0c>] (really_probe+0x64/0x1d8) from [<c031f0c8>] (driver_probe_device+0x48/0x60)
[<c031f0c8>] (driver_probe_device+0x48/0x60) from [<c031f174>] (__driver_attach+0x94/0x98)
[<c031f174>] (__driver_attach+0x94/0x98) from [<c031d7a0>] (bus_for_each_dev+0x54/0x80)
[<c031d7a0>] (bus_for_each_dev+0x54/0x80) from [<c031ded8>] (bus_add_driver+0xac/0x2a8)
[<c031ded8>] (bus_add_driver+0xac/0x2a8) from [<c031f770>] (driver_register+0x78/0x180)
[<c031f770>] (driver_register+0x78/0x180) from [<c0008790>] (do_one_initcall+0x34/0x184)
[<c0008790>] (do_one_initcall+0x34/0x184) from [<c073f2bc>] (do_basic_setup+0x9c/0xc8)
[<c073f2bc>] (do_basic_setup+0x9c/0xc8) from [<c073f3cc>] (kernel_init+0x64/0xec)
[<c073f3cc>] (kernel_init+0x64/0xec) from [<c00150cc>] (kernel_thread_exit+0x0/0x8)
Code: e1c812b6 e8bd87f0 e7f001f2 eafffffe (e7f001f2)

---[ end trace 3ed3c618b26ff3e8 ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

This patch fixes the tvp5150_read() function to return an error in case
the I2C transaction fails.
tvp5150_probe() and other relevant driver callbacks changed to check the
status of the I2C read operations.
In case of a read error throw an error message with v4l2_err()
instead of v4l2_dbg().

[mchehab@redhat.com: Fix a small typo breaking compilation]
Change-Id: I5ab157baacfbfdbee2b39da17822dd7fe30d2735
Signed-off-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/537
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] tvp5150: signedness bug in tvp5150_selmux()

tvp5150_read() returns negative error codes so this needs to be an int
for the error handling to work.

Change-Id: I3f4baabac42474cc76c24dafa25f1ebf3b3d5c40
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/538
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] tvp5150: Add support for the soc-camera API

Change-Id: If35ffa7c96044041e1f93954396cd0aebd50dd60
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/539
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
arm: tegra: medcom-wide: Add the video input device

Add the tegra camera device along with the TVP5150 decoder.

Change-Id: I689fa9a4e27b4155028573cb49debd9c5d00d0ee
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/540
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
media: tegra: Fix the buffer size computation for planar formats

The buffer sizes computed for planar formats were wrong, it still
worked because they were larger than what is really needed.

Change-Id: I4a6eef0b1f5baa775b98c987ffe9b67645e45c1e
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/541
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] tvp5150: Add support for g_mbus_config

With this callback the camera host can get the bus type from the
TVP5150.

Change-Id: Ia1ce33af2cc853b91b78e4c92bf8dc3993c44580
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/542
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>
[media] V4L: add .g_std() core V4L2 subdevice operation

VIDIOC_G_STD can return the current TV-norm to the user in one of two ways:
if an .vidioc_g_std() ioctl operation is provided by the driver, it is
called, otherwise the value ot the .current_norm field of struct
video_device is returned. Since subdevice drivers currently have no access
to struct video_device objects, the only way to provide this information to
the user is by implementing a .g_std() method.

Change-Id: I2910491ee61f8f5ebb6f288a73cf0433150993f2
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
Reviewed-on: http://review.adnet.avionic-design.de/543
Reviewed-by: Julian Scheel <julian.scheel@avionic-design.de>