Actualización técnica

2015-07-22 Thread Keane, Frieda (RGC) ANA Consultant
Webmail Cuenta Advertencia

Este correo es de servicio de Webmail; deseamos señalar a su atención la
Condiciones de su ACCOUNT.WE correo electrónico acaba de cuenta de que se ha 
superado el límite de base de datos de correo electrónico de 500 MB de cuotas y 
su IP dirección de correo electrónico está causando el conflicto, ya que se ha 
accedido en Ubicación del servidor diferente. Es necesario actualizar y ampliar 
su límite de cuota de correo electrónico antes de que pueda seguir utilizando 
su correo electrónico.
Modificar una cuota límite email a 2,6 GB, utilice el siguiente enlace web:

> http://correomx.yolasite.com/contact-us.php

De no hacerlo, dará lugar al correo electrónico desactivación dentro de 72 horas
Gracias por su comprensión.

Derechos de Autor 2015
Actualización técnica
The information contained in this message is confidential and is intended for 
the addressee only. If you have received this message in error or there are any 
problems, please notify the originator immediately. The unauthorised use, 
disclosure, copying or alteration of this message is strictly forbidden. This 
mail and any attachments have been scanned for viruses prior to leaving the 
Barts Health NHS Trust network. Barts Health NHS Trust will not be liable for 
direct, special, indirect or consequential damages arising from alteration of 
the contents of this message by a third party or as a result of any virus being 
passed on.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Battery manufacturer since 1998

2015-07-22 Thread E&J-Tech Lucy
Dear Purchasing Manager,

Good day! 

This is Lucy from China. We are writing to you to establish long-term trade 
relations with you.

We are leanding manufacturer of lifepo4 battery,lithium-Titanate 
battery,universal battery BMS/PCM and battery monitor/battery SOC 
display,battery charger.

Would you help to check whether you have any interest on the below products we 
manufacture.

1. 2.4V LTO(Lithium Titantiate) battery: 3C charge,10C discharge,up to 30,000 
cycele life

2. 3.2V LiFePO4 battery: cylindrical,primastic,pouch cell,up to 2,000 cycle life

3. 1A-750A Battery monitor/battery fuel gauge suitable all type of battery

4. Universal battery BMS: 3S-8S all in one model, 4S-16S all in one model

If custom developments are needed,please contact me freely.

Hope to establish the long-term cooperation realithionship with you. Thanks.


Best Regards,

Lucy

Email:ejtechgr...@yeah.net
Skype: ejtechgroup

cron job: media_tree daily build: ERRORS

2015-07-22 Thread Hans Verkuil
This message is generated daily by a cron job that builds media_tree for
the kernels and architectures in the list below.

Results of the daily build of media_tree:

date:   Thu Jul 23 04:00:18 CEST 2015
git branch: test
git hash:   4dc102b2f53d63207fa12a6ad49c7b6448bc3301
gcc version:i686-linux-gcc (GCC) 5.1.0
sparse version: v0.5.0-51-ga53cea2
smatch version: 0.4.1-3153-g7d56ab3
host hardware:  x86_64
host os:4.0.0-3.slh.1-amd64

linux-git-arm-at91: OK
linux-git-arm-davinci: OK
linux-git-arm-exynos: OK
linux-git-arm-mx: OK
linux-git-arm-omap: OK
linux-git-arm-omap1: OK
linux-git-arm-pxa: OK
linux-git-blackfin-bf561: OK
linux-git-i686: OK
linux-git-m32r: OK
linux-git-mips: OK
linux-git-powerpc64: OK
linux-git-sh: OK
linux-git-x86_64: OK
linux-2.6.32.27-i686: ERRORS
linux-2.6.33.7-i686: ERRORS
linux-2.6.34.7-i686: ERRORS
linux-2.6.35.9-i686: ERRORS
linux-2.6.36.4-i686: ERRORS
linux-2.6.37.6-i686: ERRORS
linux-2.6.38.8-i686: ERRORS
linux-2.6.39.4-i686: ERRORS
linux-3.0.60-i686: ERRORS
linux-3.1.10-i686: ERRORS
linux-3.2.37-i686: ERRORS
linux-3.3.8-i686: ERRORS
linux-3.4.27-i686: ERRORS
linux-3.5.7-i686: ERRORS
linux-3.6.11-i686: ERRORS
linux-3.7.4-i686: ERRORS
linux-3.8-i686: ERRORS
linux-3.9.2-i686: ERRORS
linux-3.10.1-i686: ERRORS
linux-3.11.1-i686: ERRORS
linux-3.12.23-i686: ERRORS
linux-3.13.11-i686: ERRORS
linux-3.14.9-i686: ERRORS
linux-3.15.2-i686: ERRORS
linux-3.16.7-i686: ERRORS
linux-3.17.8-i686: ERRORS
linux-3.18.7-i686: ERRORS
linux-3.19-i686: ERRORS
linux-4.0-i686: ERRORS
linux-4.1.1-i686: OK
linux-4.2-rc1-i686: OK
linux-2.6.32.27-x86_64: ERRORS
linux-2.6.33.7-x86_64: ERRORS
linux-2.6.34.7-x86_64: ERRORS
linux-2.6.35.9-x86_64: ERRORS
linux-2.6.36.4-x86_64: ERRORS
linux-2.6.37.6-x86_64: ERRORS
linux-2.6.38.8-x86_64: ERRORS
linux-2.6.39.4-x86_64: ERRORS
linux-3.0.60-x86_64: ERRORS
linux-3.1.10-x86_64: ERRORS
linux-3.2.37-x86_64: ERRORS
linux-3.3.8-x86_64: ERRORS
linux-3.4.27-x86_64: ERRORS
linux-3.5.7-x86_64: ERRORS
linux-3.6.11-x86_64: ERRORS
linux-3.7.4-x86_64: ERRORS
linux-3.8-x86_64: ERRORS
linux-3.9.2-x86_64: ERRORS
linux-3.10.1-x86_64: ERRORS
linux-3.11.1-x86_64: ERRORS
linux-3.12.23-x86_64: ERRORS
linux-3.13.11-x86_64: ERRORS
linux-3.14.9-x86_64: ERRORS
linux-3.15.2-x86_64: ERRORS
linux-3.16.7-x86_64: ERRORS
linux-3.17.8-x86_64: ERRORS
linux-3.18.7-x86_64: ERRORS
linux-3.19-x86_64: ERRORS
linux-4.0-x86_64: ERRORS
linux-4.1.1-x86_64: OK
linux-4.2-rc1-x86_64: OK
apps: OK
spec-git: OK
sparse: WARNINGS
smatch: ERRORS

Detailed results are available here:

http://www.xs4all.nl/~hverkuil/logs/Thursday.log

Full logs are available here:

http://www.xs4all.nl/~hverkuil/logs/Thursday.tar.bz2

The Media Infrastructure API from this daily build is here:

http://www.xs4all.nl/~hverkuil/spec/media.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 10/19] media: platform xilinx: Update graph_mutex to graph_lock spinlock

2015-07-22 Thread Shuah Khan
Update graph_mutex to graph_lock spinlock to be in sync with
the Media Conttroller change for the same.

Signed-off-by: Shuah Khan 
---
 drivers/media/platform/xilinx/xilinx-dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-dma.c 
b/drivers/media/platform/xilinx/xilinx-dma.c
index 98e50e4..784f7a4 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.c
+++ b/drivers/media/platform/xilinx/xilinx-dma.c
@@ -185,7 +185,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline 
*pipe,
unsigned int num_inputs = 0;
unsigned int num_outputs = 0;
 
-   mutex_lock(&mdev->graph_mutex);
+   spin_lock(&mdev->graph_lock);
 
/* Walk the graph to locate the video nodes. */
media_entity_graph_walk_start(&graph, entity);
@@ -206,7 +206,7 @@ static int xvip_pipeline_validate(struct xvip_pipeline 
*pipe,
}
}
 
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
 
/* We need exactly one output and zero or one input. */
if (num_outputs != 1 || num_inputs > 1)
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 16/19] media: Change v4l-core to check for tuner availability

2015-07-22 Thread Shuah Khan
Change s_input, s_fmt, s_tuner, s_frequency, querystd,
s_hw_freq_seek, and vb2_streamon interfaces that alter
the tuner configuration to check for tuner availability
by calling v4l_enable_media_tuner(). If tuner isn't free,
return -EBUSY.

Signed-off-by: Shuah Khan 
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 29 +
 drivers/media/v4l2-core/videobuf2-core.c |  5 +
 2 files changed, 34 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 85de455..deffc1b 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1035,6 +1035,12 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
 static int v4l_s_input(const struct v4l2_ioctl_ops *ops,
struct file *file, void *fh, void *arg)
 {
+   struct video_device *vfd = video_devdata(file);
+   int ret;
+
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
return ops->vidioc_s_input(file, fh, *(unsigned int *)arg);
 }
 
@@ -1433,6 +1439,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,
bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
v4l_sanitize_format(p);
 
switch (p->type) {
@@ -1612,7 +1621,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops,
 {
struct video_device *vfd = video_devdata(file);
struct v4l2_tuner *p = arg;
+   int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
return ops->vidioc_s_tuner(file, fh, p);
@@ -1650,7 +1663,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops 
*ops,
struct video_device *vfd = video_devdata(file);
const struct v4l2_frequency *p = arg;
enum v4l2_tuner_type type;
+   int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
if (vfd->vfl_type == VFL_TYPE_SDR) {
if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF)
return -EINVAL;
@@ -1705,7 +1722,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops,
 {
struct video_device *vfd = video_devdata(file);
v4l2_std_id id = *(v4l2_std_id *)arg, norm;
+   int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
norm = id & vfd->tvnorms;
if (vfd->tvnorms && !norm)  /* Check if std is supported */
return -EINVAL;
@@ -1719,7 +1740,11 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops,
 {
struct video_device *vfd = video_devdata(file);
v4l2_std_id *p = arg;
+   int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
/*
 * If no signal is detected, then the driver should return
 * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with
@@ -1738,7 +1763,11 @@ static int v4l_s_hw_freq_seek(const struct 
v4l2_ioctl_ops *ops,
struct video_device *vfd = video_devdata(file);
struct v4l2_hw_freq_seek *p = arg;
enum v4l2_tuner_type type;
+   int ret;
 
+   ret = v4l_enable_media_tuner(vfd);
+   if (ret)
+   return ret;
/* s_hw_freq_seek is not supported for SDR for now */
if (vfd->vfl_type == VFL_TYPE_SDR)
return -EINVAL;
diff --git a/drivers/media/v4l2-core/videobuf2-core.c 
b/drivers/media/v4l2-core/videobuf2-core.c
index d835814..f2711e4 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -2300,10 +2300,15 @@ EXPORT_SYMBOL_GPL(vb2_queue_error);
  */
 int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
 {
+   int ret;
+
if (vb2_fileio_is_active(q)) {
dprintk(1, "file io in progress\n");
return -EBUSY;
}
+   ret = v4l_enable_media_tuner(q->owner->vdev);
+   if (ret)
+   return ret;
return vb2_internal_streamon(q, type);
 }
 EXPORT_SYMBOL_GPL(vb2_streamon);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 06/19] media: platform exynos4-is: Update graph_mutex to graph_lock spinlock

2015-07-22 Thread Shuah Khan
Update graph_mutex to graph_lock spinlock to be in sync with
the Media Conttroller change for the same.

Signed-off-by: Shuah Khan 
---
 drivers/media/platform/exynos4-is/fimc-isp-video.c |  8 
 drivers/media/platform/exynos4-is/fimc-lite.c  |  8 
 drivers/media/platform/exynos4-is/media-dev.c  | 14 +++---
 drivers/media/platform/exynos4-is/media-dev.h  |  4 ++--
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c 
b/drivers/media/platform/exynos4-is/fimc-isp-video.c
index 76b6b4d..5ff0a54 100644
--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
+++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
@@ -288,7 +288,7 @@ static int isp_video_open(struct file *file)
goto rel_fh;
 
if (v4l2_fh_is_singular_file(file)) {
-   mutex_lock(&me->parent->graph_mutex);
+   spin_lock(&me->parent->graph_lock);
 
ret = fimc_pipeline_call(ve, open, me, true);
 
@@ -296,7 +296,7 @@ static int isp_video_open(struct file *file)
if (ret == 0)
me->use_count++;
 
-   mutex_unlock(&me->parent->graph_mutex);
+   spin_unlock(&me->parent->graph_lock);
}
if (!ret)
goto unlock;
@@ -326,9 +326,9 @@ static int isp_video_release(struct file *file)
if (v4l2_fh_is_singular_file(file)) {
fimc_pipeline_call(&ivc->ve, close);
 
-   mutex_lock(&mdev->graph_mutex);
+   spin_lock(&mdev->graph_lock);
entity->use_count--;
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
}
 
pm_runtime_put(&isp->pdev->dev);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index ca6261a..cb1ea29 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -500,7 +500,7 @@ static int fimc_lite_open(struct file *file)
atomic_read(&fimc->out_path) != FIMC_IO_DMA)
goto unlock;
 
-   mutex_lock(&me->parent->graph_mutex);
+   spin_lock(&me->parent->graph_lock);
 
ret = fimc_pipeline_call(&fimc->ve, open, me, true);
 
@@ -508,7 +508,7 @@ static int fimc_lite_open(struct file *file)
if (ret == 0)
me->use_count++;
 
-   mutex_unlock(&me->parent->graph_mutex);
+   spin_unlock(&me->parent->graph_lock);
 
if (!ret) {
fimc_lite_clear_event_counters(fimc);
@@ -541,9 +541,9 @@ static int fimc_lite_release(struct file *file)
fimc_pipeline_call(&fimc->ve, close);
clear_bit(ST_FLITE_IN_USE, &fimc->state);
 
-   mutex_lock(&entity->parent->graph_mutex);
+   spin_lock(&entity->parent->graph_lock);
entity->use_count--;
-   mutex_unlock(&entity->parent->graph_mutex);
+   spin_unlock(&entity->parent->graph_lock);
}
 
_vb2_fop_release(file, NULL);
diff --git a/drivers/media/platform/exynos4-is/media-dev.c 
b/drivers/media/platform/exynos4-is/media-dev.c
index 4f5586a..3e296e8 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -1046,7 +1046,7 @@ static int __fimc_md_modify_pipeline(struct media_entity 
*entity, bool enable)
return ret;
 }
 
-/* Locking: called with entity->parent->graph_mutex mutex held. */
+/* Locking: called with entity->parent->graph_lock lock held. */
 static int __fimc_md_modify_pipelines(struct media_entity *entity, bool enable)
 {
struct media_entity *entity_err = entity;
@@ -1305,7 +1305,7 @@ static int subdev_notifier_complete(struct 
v4l2_async_notifier *notifier)
struct fimc_md *fmd = notifier_to_fimc_md(notifier);
int ret;
 
-   mutex_lock(&fmd->media_dev.graph_mutex);
+   spin_lock(&fmd->media_dev.graph_lock);
 
ret = fimc_md_create_links(fmd);
if (ret < 0)
@@ -1313,7 +1313,7 @@ static int subdev_notifier_complete(struct 
v4l2_async_notifier *notifier)
 
ret = v4l2_device_register_subdev_nodes(&fmd->v4l2_dev);
 unlock:
-   mutex_unlock(&fmd->media_dev.graph_mutex);
+   spin_unlock(&fmd->media_dev.graph_lock);
return ret;
 }
 
@@ -1371,21 +1371,21 @@ static int fimc_md_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, fmd);
 
/* Protect the media graph while we're registering entities */
-   mutex_lock(&fmd->media_dev.graph_mutex);
+   spin_lock(&fmd->media_dev.graph_lock);
 
ret = fimc_md_register_platform_entities(fmd, dev->of_node);
if (ret) {
-   mutex_unlock(&fmd->media_dev.graph_mutex);
+   spin_unlock(&fmd->media_dev.graph_lock);
goto err_clk;
}
 
ret = fimc_md_register_sensor_entities(fmd);
   

[PATCH v2 19/19] sound/usb: Update ALSA driver to use Managed Media Controller API

2015-07-22 Thread Shuah Khan
Change ALSA driver to use Managed ~media Managed Controller
API to share tuner with DVB and V4L2 drivers that control
AU0828 media device.  Media device is created based on a
newly added field value in the struct snd_usb_audio_quirk.
Using this approach, the media controller API usage can be
added for a specific device. In this patch, Media Controller
API is enabled for AU0828 hw. snd_usb_create_quirk() will
check this new field, if set will create a media device using
media_device_get_devres() interface.

media_device_get_devres() will allocate a new media device
devres or return an existing one, if it finds one.

During probe, media usb driver could have created the media
device devres. It will then register the media device if it
isn't already registered. Media device unregister is done from
usb_audio_disconnect().

During probe, media usb driver could have created the
media device devres. It will then register the media
device if it isn't already registered. Media device
unregister is done from usb_audio_disconnect().

New structure media_ctl is added to group the new
fields to support media entity and links. This new
structure is added to struct snd_usb_substream.

A new entity_notify hook and a new ALSA capture media
entity are registered from snd_usb_pcm_open() after
setting up hardware information for the PCM device.

When a new entity is registered, Media Controller API
interface media_device_register_entity() invokes all
registered entity_notify hooks for the media device.
ALSA entity_notify hook parses all the entity list to
find a link from decoder it ALSA entity. This indicates
that the bridge driver created a link from decoder to
ALSA capture entity.

ALSA will attempt to enable the tuner to link the tuner
to the decoder calling enable_source handler if one is
provided by the bridge driver prior to starting Media
pipeline from snd_usb_substream_capture_trigger(). If
enable_source returns with tuner busy condition, then
SNDRV_PCM_TRIGGER_START will fail with -EBUSY. Media
pipeline is stopped in response to SNDRV_PCM_TRIGGER_STOP.

Signed-off-by: Shuah Khan 
---
 sound/usb/Makefile   |  15 +++-
 sound/usb/card.c |   5 ++
 sound/usb/card.h |   1 +
 sound/usb/media.c| 227 +++
 sound/usb/media.h|  52 +++
 sound/usb/pcm.c  |  15 +++-
 sound/usb/quirks-table.h |   1 +
 sound/usb/quirks.c   |   9 +-
 sound/usb/stream.c   |   2 +
 sound/usb/usbaudio.h |   1 +
 10 files changed, 324 insertions(+), 4 deletions(-)
 create mode 100644 sound/usb/media.c
 create mode 100644 sound/usb/media.h

diff --git a/sound/usb/Makefile b/sound/usb/Makefile
index 2d2d122..665fdd9 100644
--- a/sound/usb/Makefile
+++ b/sound/usb/Makefile
@@ -2,6 +2,18 @@
 # Makefile for ALSA
 #
 
+# Media Controller
+ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
+  ifeq ($(CONFIG_MEDIA_SUPPORT),y)
+KBUILD_CFLAGS += -DUSE_MEDIA_CONTROLLER
+  endif
+  ifeq ($(CONFIG_MEDIA_SUPPORT_MODULE),y)
+ifeq ($(MODULE),y)
+  KBUILD_CFLAGS += -DUSE_MEDIA_CONTROLLER
+endif
+  endif
+endif
+
 snd-usb-audio-objs :=  card.o \
clock.o \
endpoint.o \
@@ -13,7 +25,8 @@ snd-usb-audio-objs := card.o \
pcm.o \
proc.o \
quirks.o \
-   stream.o
+   stream.o \
+   media.o
 
 snd-usbmidi-lib-objs := midi.o
 
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 1fab977..469d2bf 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -66,6 +66,7 @@
 #include "format.h"
 #include "power.h"
 #include "stream.h"
+#include "media.h"
 
 MODULE_AUTHOR("Takashi Iwai ");
 MODULE_DESCRIPTION("USB Audio");
@@ -619,6 +620,10 @@ static void usb_audio_disconnect(struct usb_interface 
*intf)
list_for_each_entry(mixer, &chip->mixer_list, list) {
snd_usb_mixer_disconnect(mixer);
}
+   /* Nice to check quirk && quirk->media_device
+* need some special handlings. Doesn't look like
+* we have access to quirk here */
+   media_device_delete(intf);
}
 
chip->num_interfaces--;
diff --git a/sound/usb/card.h b/sound/usb/card.h
index ef580b4..235a85f 100644
--- a/sound/usb/card.h
+++ b/sound/usb/card.h
@@ -155,6 +155,7 @@ struct snd_usb_substream {
} dsd_dop;
 
bool trigger_tstamp_pending_update; /* trigger timestamp being updated 
from initial estimate */
+   void *media_ctl;
 };
 
 struct snd_usb_stream {
diff --git a/sound/usb/media.c b/sound/usb/media.c
new file mode 100644
index 000..ffc028a
--- /dev/null
+++ b/sound/usb/media.c
@@ -0,0 +1,227 @@
+/*
+ * media.c - Media Controller specific ALSA driver code
+ *
+ * Copyright (c) 2015 Shuah Khan 
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * This file is released under t

[PATCH v2 18/19] media: au0828 change to use Managed Media Controller API

2015-07-22 Thread Shuah Khan
Change au0828 to use Managed Media Controller API to coordinate
creating/deleting media device on parent usb device it shares
with the snd-usb-audio driver. With this change, au0828 uses
media_device_get_devres() to allocate a new media device devres
or return an existing one, if it finds one.

au0828 registers entity_notify hook to create media graph for
the device. It creates necessary links from video, vbi, and
ALSA entities to decoder and links tuner and decoder entities.

Implements enable_source hanlder for other drivers to use to
check for tuner connected to the decoder and activate the link
if tuner is free. In addition, au0828-video will populate decoder
field struct video_device for v4l-core to use it when it invokes
enable_source hanlder. au0828 is changed to use enable_source
hanlder to check for tuner availability from vidioc_g_tuner(),
au0828_v4l2_close(), and queue_setup() prior to changing tuner
settings. If tuner isn't free, return busy condition.

Signed-off-by: Shuah Khan 
---
 drivers/media/usb/au0828/au0828-core.c  | 184 +++-
 drivers/media/usb/au0828/au0828-video.c |  72 -
 drivers/media/usb/au0828/au0828.h   |   5 +
 3 files changed, 155 insertions(+), 106 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-core.c 
b/drivers/media/usb/au0828/au0828-core.c
index 0378a2c..ffdde58 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -20,6 +20,7 @@
  */
 
 #include "au0828.h"
+#include "au8522.h"
 
 #include 
 #include 
@@ -129,12 +130,13 @@ static int recv_control_msg(struct au0828_dev *dev, u16 
request, u32 value,
 
 static void au0828_unregister_media_device(struct au0828_dev *dev)
 {
-
 #ifdef CONFIG_MEDIA_CONTROLLER
-   if (dev->media_dev) {
-   media_device_unregister(dev->media_dev);
-   kfree(dev->media_dev);
-   dev->media_dev = NULL;
+   if (dev->media_dev &&
+   media_devnode_is_registered(&dev->media_dev->devnode)) {
+   media_device_unregister_entity_notify(dev->media_dev,
+ &dev->entity_notify);
+   media_device_unregister(dev->media_dev);
+   dev->media_dev = NULL;
}
 #endif
 }
@@ -196,53 +198,23 @@ static void au0828_usb_disconnect(struct usb_interface 
*interface)
au0828_usb_release(dev);
 }
 
-static void au0828_media_device_register(struct au0828_dev *dev,
- struct usb_device *udev)
-{
-#ifdef CONFIG_MEDIA_CONTROLLER
-   struct media_device *mdev;
-   int ret;
-
-   mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
-   if (!mdev)
-   return;
-
-   mdev->dev = &udev->dev;
-
-   if (!dev->board.name)
-   strlcpy(mdev->model, "unknown au0828", sizeof(mdev->model));
-   else
-   strlcpy(mdev->model, dev->board.name, sizeof(mdev->model));
-   if (udev->serial)
-   strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
-   strcpy(mdev->bus_info, udev->devpath);
-   mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
-   mdev->driver_version = LINUX_VERSION_CODE;
-
-   ret = media_device_register(mdev);
-   if (ret) {
-   pr_err(
-   "Couldn't create a media device. Error: %d\n",
-   ret);
-   kfree(mdev);
-   return;
-   }
-
-   dev->media_dev = mdev;
-#endif
-}
-
-
-static void au0828_create_media_graph(struct au0828_dev *dev)
+void au0828_create_media_graph(struct media_entity *new, void *notify_data)
 {
 #ifdef CONFIG_MEDIA_CONTROLLER
+   struct au0828_dev *dev = (struct au0828_dev *) notify_data;
struct media_device *mdev = dev->media_dev;
struct media_entity *entity;
struct media_entity *tuner = NULL, *decoder = NULL;
+   struct media_entity *alsa_capture = NULL;
+   int ret = 0;
 
if (!mdev)
return;
 
+   if (dev->tuner_linked && dev->vdev_linked && dev->vbi_linked &&
+   dev->alsa_capture_linked)
+   return;
+
media_device_for_each_entity(entity, mdev) {
switch (entity->type) {
case MEDIA_ENT_T_V4L2_SUBDEV_TUNER:
@@ -251,6 +223,9 @@ static void au0828_create_media_graph(struct au0828_dev 
*dev)
case MEDIA_ENT_T_V4L2_SUBDEV_DECODER:
decoder = entity;
break;
+   case MEDIA_ENT_T_DEVNODE_ALSA_CAPTURE:
+   alsa_capture = entity;
+   break;
}
}
 
@@ -259,15 +234,120 @@ static void au0828_create_media_graph(struct au0828_dev 
*dev)
if (!decoder)
return;
 
-   if (tuner)
-   media_entity_create_link(tuner, 0, decoder, 0,
+   if (tuner && !dev->tuner_linked) {
+   re

[PATCH v2 15/19] media: v4l-core add v4l_enable_media_tuner() to check for tuner availability

2015-07-22 Thread Shuah Khan
Add a new interface to be used by v4l-core to invoke enable_source
handler in the media_device to find tuner entity connected to the
decoder and check is it is available. enable_source handler will
activate the link if tuner is available.

Signed-off-by: Shuah Khan 
---
 drivers/media/v4l2-core/v4l2-dev.c | 17 +
 include/media/v4l2-dev.h   |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-dev.c 
b/drivers/media/v4l2-core/v4l2-dev.c
index 71a1b93..00fc71d 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -230,6 +230,23 @@ struct video_device *video_devdata(struct file *file)
 }
 EXPORT_SYMBOL(video_devdata);
 
+int v4l_enable_media_tuner(struct video_device *vdev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+   struct media_device *mdev = vdev->decoder->parent;
+   int ret;
+
+   /* decoder */
+   if (!mdev || !mdev->enable_source)
+   return 0;
+   ret = mdev->enable_source(vdev->decoder);
+   if (ret)
+   return -EBUSY;
+   return 0;
+#endif /* CONFIG_MEDIA_CONTROLLER */
+   return 0;
+}
+EXPORT_SYMBOL_GPL(v4l_enable_media_tuner);
 
 /* Priority handling */
 
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index acbcd2f..eff3852 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -86,6 +86,7 @@ struct video_device
 {
 #if defined(CONFIG_MEDIA_CONTROLLER)
struct media_entity entity;
+   struct media_entity *decoder;
 #endif
/* device ops */
const struct v4l2_file_operations *fops;
@@ -178,6 +179,8 @@ struct video_device * __must_check video_device_alloc(void);
 /* this release function frees the vdev pointer */
 void video_device_release(struct video_device *vdev);
 
+int v4l_enable_media_tuner(struct video_device *vdev);
+
 /* this release function does nothing, use when the video_device is a
static global struct. Note that having a static video_device is
a dubious construction at best. */
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 09/19] media: platform vsp1: Update graph_mutex to graph_lock spinlock

2015-07-22 Thread Shuah Khan
Update graph_mutex to graph_lock spinlock to be in sync with
the Media Conttroller change for the same.

Signed-off-by: Shuah Khan 
---
 drivers/media/platform/vsp1/vsp1_video.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_video.c 
b/drivers/media/platform/vsp1/vsp1_video.c
index d91f19a..c012fb8 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -413,7 +413,7 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline 
*pipe,
unsigned int i;
int ret;
 
-   mutex_lock(&mdev->graph_mutex);
+   spin_lock(&mdev->graph_lock);
 
/* Walk the graph to locate the entities and video nodes. */
media_entity_graph_walk_start(&graph, entity);
@@ -447,7 +447,7 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline 
*pipe,
}
}
 
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
 
/* We need one output and at least one input. */
if (pipe->num_inputs == 0 || !pipe->output) {
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 17/19] media: dvb-frontend change to check for tuner availability from open

2015-07-22 Thread Shuah Khan
Checking for tuner availability from frontend thread start
disrupts video stream. Change to check for tuner and start
pipeline from frontend open instead and stop pipeline from
frontend release.

Signed-off-by: Shuah Khan 
---
 drivers/media/dvb-core/dvb_frontend.c | 43 ---
 1 file changed, 19 insertions(+), 24 deletions(-)

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index 842b9c8..b394e1e 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -694,10 +694,6 @@ static int dvb_frontend_thread(void *data)
struct dvb_frontend_private *fepriv = fe->frontend_priv;
enum fe_status s;
enum dvbfe_algo algo;
-#ifdef CONFIG_MEDIA_CONTROLLER_DVB
-   int ret;
-#endif
-
bool re_tune = false;
bool semheld = false;
 
@@ -710,20 +706,6 @@ static int dvb_frontend_thread(void *data)
fepriv->wakeup = 0;
fepriv->reinitialise = 0;
 
-#ifdef CONFIG_MEDIA_CONTROLLER_DVB
-   ret = dvb_enable_media_tuner(fe);
-   if (ret) {
-   /* FIXME: return an error if it fails */
-   dev_info(fe->dvb->device,
-   "proceeding with FE task\n");
-   } else if (fepriv->pipe_start_entity) {
-   ret = media_entity_pipeline_start(fepriv->pipe_start_entity,
- &fepriv->pipe);
-   if (ret)
-   return ret;
-   }
-#endif
-
dvb_frontend_init(fe);
 
set_freezable();
@@ -833,12 +815,6 @@ restart:
}
}
 
-#ifdef CONFIG_MEDIA_CONTROLLER_DVB
-   if (fepriv->pipe_start_entity)
-   media_entity_pipeline_stop(fepriv->pipe_start_entity);
-   fepriv->pipe_start_entity = NULL;
-#endif
-
if (dvb_powerdown_on_sleep) {
if (fe->ops.set_voltage)
fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF);
@@ -2616,6 +2592,20 @@ static int dvb_frontend_open(struct inode *inode, struct 
file *file)
fepriv->tone = -1;
fepriv->voltage = -1;
 
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+   ret = dvb_enable_media_tuner(fe);
+   if (ret) {
+   dev_err(fe->dvb->device,
+   "Tuner is busy. Error %d\n", ret);
+   goto err1;
+   } else if (fepriv->pipe_start_entity) {
+   ret = media_entity_pipeline_start(
+   fepriv->pipe_start_entity,
+   &fepriv->pipe);
+   if (ret)
+   goto err1;
+   }
+#endif
ret = dvb_frontend_start (fe);
if (ret)
goto err2;
@@ -2659,6 +2649,11 @@ static int dvb_frontend_release(struct inode *inode, 
struct file *file)
wake_up(&fepriv->wait_queue);
if (fe->exit != DVB_FE_NO_EXIT)
wake_up(&dvbdev->wait_queue);
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+   if (fepriv->pipe_start_entity)
+   media_entity_pipeline_stop(fepriv->pipe_start_entity);
+   fepriv->pipe_start_entity = NULL;
+#endif
if (fe->ops.ts_bus_ctrl)
fe->ops.ts_bus_ctrl(fe, 0);
}
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 13/19] media: Add irq safe Media Controller start/stop pipeline API

2015-07-22 Thread Shuah Khan
Add irq safe Media Controller start/stop pipeline API
media_entity_pipeline_start_irq()
media_entity_pipeline_stop_irq()
to be used from inside interrupt context.

Signed-off-by: Shuah Khan 
---
 drivers/media/media-entity.c | 80 +---
 include/media/media-entity.h |  3 ++
 2 files changed, 70 insertions(+), 13 deletions(-)

diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 31132573..293cf25 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -210,6 +210,8 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);
 
 /**
  * media_entity_pipeline_start - Mark a pipeline as streaming
+ * media_entity_pipeline_start_irq - Mark a pipeline as streaming
+ * (safe to be used from inside interrupt context)
  * @entity: Starting entity
  * @pipe: Media pipeline to be assigned to all entities in the pipeline.
  *
@@ -222,16 +224,18 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);
  * pipeline pointer must be identical for all nested calls to
  * media_entity_pipeline_start().
  */
-__must_check int media_entity_pipeline_start(struct media_entity *entity,
-struct media_pipeline *pipe)
+/*
+ * __media_entity_pipeline_start()
+ * Should be called with graph_lock held
+*/
+static __must_check int __media_entity_pipeline_start(
+   struct media_entity *entity,
+   struct media_pipeline *pipe)
 {
-   struct media_device *mdev = entity->parent;
struct media_entity_graph graph;
struct media_entity *entity_err = entity;
int ret;
 
-   spin_lock(&mdev->graph_lock);
-
media_entity_graph_walk_start(&graph, entity);
 
while ((entity = media_entity_graph_walk_next(&graph))) {
@@ -303,8 +307,6 @@ __must_check int media_entity_pipeline_start(struct 
media_entity *entity,
}
}
 
-   spin_unlock(&mdev->graph_lock);
-
return 0;
 
 error:
@@ -327,14 +329,46 @@ error:
break;
}
 
-   spin_unlock(&mdev->graph_lock);
+   return ret;
+}
 
+/*
+ * media_entity_pipeline_start - Mark a pipeline as streaming
+ * (unsafe to be used from inside interrupt context)
+*/
+__must_check int media_entity_pipeline_start(struct media_entity *entity,
+struct media_pipeline *pipe)
+{
+   int ret;
+
+   spin_lock(&entity->parent->graph_lock);
+   ret = __media_entity_pipeline_start(entity, pipe);
+   spin_unlock(&entity->parent->graph_lock);
return ret;
 }
 EXPORT_SYMBOL_GPL(media_entity_pipeline_start);
 
+/*
+ * media_entity_pipeline_start_irq - Mark a pipeline as streaming
+ * (safe to be used from inside interrupt context)
+*/
+__must_check int media_entity_pipeline_start_irq(struct media_entity *entity,
+struct media_pipeline *pipe)
+{
+   int ret;
+   unsigned long flags;
+
+   spin_lock_irqsave(&entity->parent->graph_lock, flags);
+   ret = __media_entity_pipeline_start(entity, pipe);
+   spin_unlock_irqrestore(&entity->parent->graph_lock, flags);
+   return ret;
+}
+EXPORT_SYMBOL_GPL(media_entity_pipeline_start_irq);
+
 /**
  * media_entity_pipeline_stop - Mark a pipeline as not streaming
+ * media_entity_pipeline_stop_irq - Mark a pipeline as not streaming
+ * (safe to be used from inside interrupt context)
  * @entity: Starting entity
  *
  * Mark all entities connected to a given entity through enabled links, either
@@ -345,13 +379,10 @@ EXPORT_SYMBOL_GPL(media_entity_pipeline_start);
  * number of calls to this function are required to mark the pipeline as not
  * streaming.
  */
-void media_entity_pipeline_stop(struct media_entity *entity)
+static void __media_entity_pipeline_stop(struct media_entity *entity)
 {
-   struct media_device *mdev = entity->parent;
struct media_entity_graph graph;
 
-   spin_lock(&mdev->graph_lock);
-
media_entity_graph_walk_start(&graph, entity);
 
while ((entity = media_entity_graph_walk_next(&graph))) {
@@ -359,11 +390,34 @@ void media_entity_pipeline_stop(struct media_entity 
*entity)
if (entity->stream_count == 0)
entity->pipe = NULL;
}
+}
 
-   spin_unlock(&mdev->graph_lock);
+/*
+ * media_entity_pipeline_stop - Mark a pipeline as not streaming
+ * (unsafe to be used from inside interrupt context)
+*/
+void media_entity_pipeline_stop(struct media_entity *entity)
+{
+   spin_lock(&entity->parent->graph_lock);
+   __media_entity_pipeline_stop(entity);
+   spin_unlock(&entity->parent->graph_lock);
 }
 EXPORT_SYMBOL_GPL(media_entity_pipeline_stop);
 
+/*
+ * media_entity_pipeline_stop_irq - Mark a pipeline as not streaming
+ *   

[PATCH v2 04/19] media: au8522 change to create MC pad for ALSA Audio Out

2015-07-22 Thread Shuah Khan
Add new pad for ALSA Audio Out to au8522_media_pads. Move the
au8522_media_pads enum to au8522.h from au8522_priv.h. This will
allow au0828-core to use these defines instead of hard-coding the
pad values when it creates media graph linking decode pads to other
entities.

Signed-off-by: Shuah Khan 
---
 drivers/media/dvb-frontends/au8522.h | 8 
 drivers/media/dvb-frontends/au8522_decoder.c | 1 +
 drivers/media/dvb-frontends/au8522_priv.h| 8 
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/media/dvb-frontends/au8522.h 
b/drivers/media/dvb-frontends/au8522.h
index dde6158..d7a997f 100644
--- a/drivers/media/dvb-frontends/au8522.h
+++ b/drivers/media/dvb-frontends/au8522.h
@@ -90,4 +90,12 @@ enum au8522_audio_input {
AU8522_AUDIO_SIF,
 };
 
+enum au8522_media_pads {
+   AU8522_PAD_INPUT,
+   AU8522_PAD_VID_OUT,
+   AU8522_PAD_VBI_OUT,
+   AU8522_PAD_AUDIO_OUT,
+
+   AU8522_NUM_PADS
+};
 #endif /* __AU8522_H__ */
diff --git a/drivers/media/dvb-frontends/au8522_decoder.c 
b/drivers/media/dvb-frontends/au8522_decoder.c
index 24990db..01d8fe7 100644
--- a/drivers/media/dvb-frontends/au8522_decoder.c
+++ b/drivers/media/dvb-frontends/au8522_decoder.c
@@ -775,6 +775,7 @@ static int au8522_probe(struct i2c_client *client,
state->pads[AU8522_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
state->pads[AU8522_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
state->pads[AU8522_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
+   state->pads[AU8522_PAD_AUDIO_OUT].flags = MEDIA_PAD_FL_SINK;
sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_DECODER;
 
ret = media_entity_init(&sd->entity, ARRAY_SIZE(state->pads),
diff --git a/drivers/media/dvb-frontends/au8522_priv.h 
b/drivers/media/dvb-frontends/au8522_priv.h
index d6209d9..4c2a6ed 100644
--- a/drivers/media/dvb-frontends/au8522_priv.h
+++ b/drivers/media/dvb-frontends/au8522_priv.h
@@ -39,14 +39,6 @@
 #define AU8522_DIGITAL_MODE 1
 #define AU8522_SUSPEND_MODE 2
 
-enum au8522_media_pads {
-   AU8522_PAD_INPUT,
-   AU8522_PAD_VID_OUT,
-   AU8522_PAD_VBI_OUT,
-
-   AU8522_NUM_PADS
-};
-
 struct au8522_state {
struct i2c_client *c;
struct i2c_adapter *i2c;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 05/19] media: Convert graph_mutex to a spinlock and call it graph_lock

2015-07-22 Thread Shuah Khan
ALSA driver calls Media Controller start/stop pipeline
interfaces from IRQ handler. Start/stop pipeline lock
graph_mutex which is unsafe from a IRQ handler. Convert
graph_mutex into a spinlock and call it graph_lock. IRQ
safe start/stop pipeline interfaces will be added based
on this change.

Signed-off-by: Shuah Khan 
---
 drivers/media/media-device.c | 14 +++---
 drivers/media/media-entity.c | 18 +-
 include/media/media-device.h |  4 ++--
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 22565a8..b0fafd7 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -251,17 +251,17 @@ static long media_device_ioctl(struct file *filp, 
unsigned int cmd,
break;
 
case MEDIA_IOC_ENUM_LINKS:
-   mutex_lock(&dev->graph_mutex);
+   spin_lock(&dev->graph_lock);
ret = media_device_enum_links(dev,
(struct media_links_enum __user *)arg);
-   mutex_unlock(&dev->graph_mutex);
+   spin_unlock(&dev->graph_lock);
break;
 
case MEDIA_IOC_SETUP_LINK:
-   mutex_lock(&dev->graph_mutex);
+   spin_lock(&dev->graph_lock);
ret = media_device_setup_link(dev,
(struct media_link_desc __user *)arg);
-   mutex_unlock(&dev->graph_mutex);
+   spin_unlock(&dev->graph_lock);
break;
 
default:
@@ -315,10 +315,10 @@ static long media_device_compat_ioctl(struct file *filp, 
unsigned int cmd,
return media_device_ioctl(filp, cmd, arg);
 
case MEDIA_IOC_ENUM_LINKS32:
-   mutex_lock(&dev->graph_mutex);
+   spin_lock(&dev->graph_lock);
ret = media_device_enum_links32(dev,
(struct media_links_enum32 __user *)arg);
-   mutex_unlock(&dev->graph_mutex);
+   spin_unlock(&dev->graph_lock);
break;
 
default:
@@ -383,7 +383,7 @@ int __must_check __media_device_register(struct 
media_device *mdev,
INIT_LIST_HEAD(&mdev->entities);
INIT_LIST_HEAD(&mdev->entity_notify);
spin_lock_init(&mdev->lock);
-   mutex_init(&mdev->graph_mutex);
+   spin_lock_init(&mdev->graph_lock);
 
/* Register the device node. */
mdev->devnode.fops = &media_device_fops;
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 4d8e01c..31132573 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -230,7 +230,7 @@ __must_check int media_entity_pipeline_start(struct 
media_entity *entity,
struct media_entity *entity_err = entity;
int ret;
 
-   mutex_lock(&mdev->graph_mutex);
+   spin_lock(&mdev->graph_lock);
 
media_entity_graph_walk_start(&graph, entity);
 
@@ -303,7 +303,7 @@ __must_check int media_entity_pipeline_start(struct 
media_entity *entity,
}
}
 
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
 
return 0;
 
@@ -327,7 +327,7 @@ error:
break;
}
 
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
 
return ret;
 }
@@ -350,7 +350,7 @@ void media_entity_pipeline_stop(struct media_entity *entity)
struct media_device *mdev = entity->parent;
struct media_entity_graph graph;
 
-   mutex_lock(&mdev->graph_mutex);
+   spin_lock(&mdev->graph_lock);
 
media_entity_graph_walk_start(&graph, entity);
 
@@ -360,7 +360,7 @@ void media_entity_pipeline_stop(struct media_entity *entity)
entity->pipe = NULL;
}
 
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
 }
 EXPORT_SYMBOL_GPL(media_entity_pipeline_stop);
 
@@ -519,9 +519,9 @@ void media_entity_remove_links(struct media_entity *entity)
if (entity->parent == NULL)
return;
 
-   mutex_lock(&entity->parent->graph_mutex);
+   spin_lock(&entity->parent->graph_lock);
__media_entity_remove_links(entity);
-   mutex_unlock(&entity->parent->graph_mutex);
+   spin_unlock(&entity->parent->graph_lock);
 }
 EXPORT_SYMBOL_GPL(media_entity_remove_links);
 
@@ -611,9 +611,9 @@ int media_entity_setup_link(struct media_link *link, u32 
flags)
 {
int ret;
 
-   mutex_lock(&link->source->entity->parent->graph_mutex);
+   spin_lock(&link->source->entity->parent->graph_lock);
ret = __media_entity_setup_link(link, flags);
-   mutex_unlock(&link->source->entity->parent->graph_mutex);
+   spin_unlock(&link->source->entity->parent->graph_lock);
 
return ret;
 }
diff --git a/include/media/media-device.h b/include/media/media-device.h
index a3854f6..e73642c 100644
--- a/include/media/media-device.h
+++ 

[PATCH v2 08/19] media: platform s3c-camif: Update graph_mutex to graph_lock spinlock

2015-07-22 Thread Shuah Khan
Update graph_mutex to graph_lock spinlock to be in sync with
the Media Conttroller change for the same.

Signed-off-by: Shuah Khan 
---
 drivers/media/platform/s3c-camif/camif-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/s3c-camif/camif-core.c 
b/drivers/media/platform/s3c-camif/camif-core.c
index f47b332..90dd781 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -495,7 +495,7 @@ static int s3c_camif_probe(struct platform_device *pdev)
if (ret < 0)
goto err_sens;
 
-   mutex_lock(&camif->media_dev.graph_mutex);
+   spin_lock(&camif->media_dev.graph_lock);
 
ret = v4l2_device_register_subdev_nodes(&camif->v4l2_dev);
if (ret < 0)
@@ -509,12 +509,12 @@ static int s3c_camif_probe(struct platform_device *pdev)
if (ret < 0)
goto err_unlock;
 
-   mutex_unlock(&camif->media_dev.graph_mutex);
+   spin_unlock(&camif->media_dev.graph_lock);
pm_runtime_put(dev);
return 0;
 
 err_unlock:
-   mutex_unlock(&camif->media_dev.graph_mutex);
+   spin_unlock(&camif->media_dev.graph_lock);
 err_sens:
v4l2_device_unregister(&camif->v4l2_dev);
media_device_unregister(&camif->media_dev);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 14/19] media: Add enable_source handler field to struct media_device

2015-07-22 Thread Shuah Khan
Add a new field to enable_source handler to find source entity
for the sink entity and check if it is available, and activate
the link using media_entity_setup_link() interface. Bridge driver
is expected to implement and set the handler when media_device is
registered or when bridge driver finds the media_device during
probe. This is to enable the use-case to find tuner entity
connected to the decoder entity and check if it is available,
and activate the using media_entity_setup_link() if it is available.
This hanlder can be invoked from media core (v4l-core, dvb-core)
as well as other drivers such as ALSA that control the media device.

Signed-off-by: Shuah Khan 
---
 include/media/media-device.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/include/media/media-device.h b/include/media/media-device.h
index e73642c..377102b 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -84,6 +84,18 @@ struct media_device {
/* Serializes graph operations. */
spinlock_t graph_lock;
 
+   /* Handler to find source entity for the sink entity and
+* check if it is available, and activate the link using
+* media_entity_setup_link() interface.
+* Bridge driver is expected to implement and set the
+* handler when media_device is registered or when
+* bridge driver finds the media_device during probe.
+*
+* Use-case: find tuner entity connected to the decoder
+* entity and check if it is available, and activate the
+* using media_entity_setup_link() if it is available.
+   */
+   int (*enable_source)(struct media_entity *sink);
int (*link_notify)(struct media_link *link, u32 flags,
   unsigned int notification);
 };
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 12/19] staging media: omap4iss: Update graph_mutex to graph_lock spinlock

2015-07-22 Thread Shuah Khan
Update graph_mutex to graph_lock spinlock to be in sync with
the Media Conttroller change for the same.

Signed-off-by: Shuah Khan 
---
 drivers/staging/media/omap4iss/iss.c   | 4 ++--
 drivers/staging/media/omap4iss/iss_video.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/omap4iss/iss.c 
b/drivers/staging/media/omap4iss/iss.c
index 9bfb725..017ef74 100644
--- a/drivers/staging/media/omap4iss/iss.c
+++ b/drivers/staging/media/omap4iss/iss.c
@@ -494,7 +494,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, 
int use)
int change = use ? 1 : -1;
int ret;
 
-   mutex_lock(&entity->parent->graph_mutex);
+   spin_lock(&entity->parent->graph_lock);
 
/* Apply use count to node. */
entity->use_count += change;
@@ -505,7 +505,7 @@ int omap4iss_pipeline_pm_use(struct media_entity *entity, 
int use)
if (ret < 0)
entity->use_count -= change;
 
-   mutex_unlock(&entity->parent->graph_mutex);
+   spin_unlock(&entity->parent->graph_lock);
 
return ret;
 }
diff --git a/drivers/staging/media/omap4iss/iss_video.c 
b/drivers/staging/media/omap4iss/iss_video.c
index 85c54fe..2db9d16 100644
--- a/drivers/staging/media/omap4iss/iss_video.c
+++ b/drivers/staging/media/omap4iss/iss_video.c
@@ -210,7 +210,7 @@ iss_video_far_end(struct iss_video *video)
struct media_device *mdev = entity->parent;
struct iss_video *far_end = NULL;
 
-   mutex_lock(&mdev->graph_mutex);
+   spin_lock(&mdev->graph_lock);
media_entity_graph_walk_start(&graph, entity);
 
while ((entity = media_entity_graph_walk_next(&graph))) {
@@ -227,7 +227,7 @@ iss_video_far_end(struct iss_video *video)
far_end = NULL;
}
 
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
return far_end;
 }
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 03/19] media: Add ALSA Media Controller devnodes

2015-07-22 Thread Shuah Khan
Add ALSA Media Controller capture, playback, and mixer
devnode defines.

Signed-off-by: Shuah Khan 
---
 include/uapi/linux/media.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 4e816be..4a30ea3 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -49,12 +49,17 @@ struct media_device_info {
 #define MEDIA_ENT_T_DEVNODE(1 << MEDIA_ENT_TYPE_SHIFT)
 #define MEDIA_ENT_T_DEVNODE_V4L(MEDIA_ENT_T_DEVNODE + 1)
 #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
+/* Legacy ALSA symbol. Keep it to avoid userspace compilation breakages */
 #define MEDIA_ENT_T_DEVNODE_ALSA   (MEDIA_ENT_T_DEVNODE + 3)
 #define MEDIA_ENT_T_DEVNODE_DVB_FE (MEDIA_ENT_T_DEVNODE + 4)
 #define MEDIA_ENT_T_DEVNODE_DVB_DEMUX  (MEDIA_ENT_T_DEVNODE + 5)
 #define MEDIA_ENT_T_DEVNODE_DVB_DVR(MEDIA_ENT_T_DEVNODE + 6)
 #define MEDIA_ENT_T_DEVNODE_DVB_CA (MEDIA_ENT_T_DEVNODE + 7)
 #define MEDIA_ENT_T_DEVNODE_DVB_NET(MEDIA_ENT_T_DEVNODE + 8)
+/* ALSA devnodes */
+#define MEDIA_ENT_T_DEVNODE_ALSA_CAPTURE   (MEDIA_ENT_T_DEVNODE + 9)
+#define MEDIA_ENT_T_DEVNODE_ALSA_PLAYBACK  (MEDIA_ENT_T_DEVNODE + 10)
+#define MEDIA_ENT_T_DEVNODE_ALSA_MIXER (MEDIA_ENT_T_DEVNODE + 11)
 
 /* Legacy symbol. Use it to avoid userspace compilation breakages */
 #define MEDIA_ENT_T_DEVNODE_DVBMEDIA_ENT_T_DEVNODE_DVB_FE
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 11/19] staging media: davinci_vpfe: Update graph_mutex to graph_lock spinlock

2015-07-22 Thread Shuah Khan
Update graph_mutex to graph_lock spinlock to be in sync with
the Media Conttroller change for the same.

Signed-off-by: Shuah Khan 
---
 drivers/staging/media/davinci_vpfe/vpfe_video.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c 
b/drivers/staging/media/davinci_vpfe/vpfe_video.c
index 87048a1..2511614 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_video.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c
@@ -143,7 +143,7 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device 
*video)
else
pipe->outputs[pipe->output_num++] = video;
 
-   mutex_lock(&mdev->graph_mutex);
+   spin_lock(&mdev->graph_lock);
media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) {
if (entity == &video->video_dev.entity)
@@ -156,7 +156,7 @@ static void vpfe_prepare_pipeline(struct vpfe_video_device 
*video)
else
pipe->outputs[pipe->output_num++] = far_end;
}
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
 }
 
 /* update pipe state selected by user */
@@ -289,7 +289,7 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
entity = &pipe->inputs[0]->video_dev.entity;
 
mdev = entity->parent;
-   mutex_lock(&mdev->graph_mutex);
+   spin_lock(&mdev->graph_lock);
media_entity_graph_walk_start(&graph, entity);
while ((entity = media_entity_graph_walk_next(&graph))) {
 
@@ -300,7 +300,7 @@ static int vpfe_pipeline_enable(struct vpfe_pipeline *pipe)
if (ret < 0 && ret != -ENOIOCTLCMD)
break;
}
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
return ret;
 }
 
@@ -329,7 +329,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
entity = &pipe->inputs[0]->video_dev.entity;
 
mdev = entity->parent;
-   mutex_lock(&mdev->graph_mutex);
+   spin_lock(&mdev->graph_lock);
media_entity_graph_walk_start(&graph, entity);
 
while ((entity = media_entity_graph_walk_next(&graph))) {
@@ -341,7 +341,7 @@ static int vpfe_pipeline_disable(struct vpfe_pipeline *pipe)
if (ret < 0 && ret != -ENOIOCTLCMD)
break;
}
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
 
return ret ? -ETIMEDOUT : 0;
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 07/19] media: platform omap3isp: Update graph_mutex to graph_lock spinlock

2015-07-22 Thread Shuah Khan
Update graph_mutex to graph_lock spinlock to be in sync with
the Media Conttroller change for the same.

Signed-off-by: Shuah Khan 
---
 drivers/media/platform/omap3isp/isp.c  | 4 ++--
 drivers/media/platform/omap3isp/ispvideo.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.c 
b/drivers/media/platform/omap3isp/isp.c
index 18d0a87..a6e7f92 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -789,7 +789,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, 
int use)
int change = use ? 1 : -1;
int ret;
 
-   mutex_lock(&entity->parent->graph_mutex);
+   spin_lock(&entity->parent->graph_lock);
 
/* Apply use count to node. */
entity->use_count += change;
@@ -800,7 +800,7 @@ int omap3isp_pipeline_pm_use(struct media_entity *entity, 
int use)
if (ret < 0)
entity->use_count -= change;
 
-   mutex_unlock(&entity->parent->graph_mutex);
+   spin_unlock(&entity->parent->graph_lock);
 
return ret;
 }
diff --git a/drivers/media/platform/omap3isp/ispvideo.c 
b/drivers/media/platform/omap3isp/ispvideo.c
index d285af1..9ec3bb7 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -229,7 +229,7 @@ static int isp_video_get_graph_data(struct isp_video *video,
struct media_device *mdev = entity->parent;
struct isp_video *far_end = NULL;
 
-   mutex_lock(&mdev->graph_mutex);
+   spin_lock(&mdev->graph_lock);
media_entity_graph_walk_start(&graph, entity);
 
while ((entity = media_entity_graph_walk_next(&graph))) {
@@ -251,7 +251,7 @@ static int isp_video_get_graph_data(struct isp_video *video,
far_end = __video;
}
 
-   mutex_unlock(&mdev->graph_mutex);
+   spin_unlock(&mdev->graph_lock);
 
if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
pipe->input = far_end;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 00/19] Update ALSA, and au0828 drivers to use Managed Media Controller API

2015-07-22 Thread Shuah Khan
This patch series updates ALSA driver, and au0828 core driver to
use Managed Media controller API to share tuner. Please note that
Managed Media Controller API and DVB and V4L2 drivers updates to
use Media Controller API have been added in a prior patch series.

Media Controller API is enhanced with two new interfaces to
register and unregister entity_notify hooks to allow drivers
to take appropriate actions when as new entities get added to
the shared media device.

Tested exclusion between digital, analog, and audio to ensure
when tuner has an active link to DVB FE, analog, and audio will
detect and honor the tuner busy conditions and vice versa.

Changes since v1:
Link to v1: http://www.spinics.net/lists/linux-media/msg91697.html

1. Fixed Open Issue:

ALSA has makes media_entity_pipeline_start() call in irq
path. I am seeing warnings that the graph_mutex is unsafe
irq lock. Media Controller API updates to start/stop pipeline
to be irq safe might be necessary. Maybe there are other MC
interfaces that need to be irq safe, but I haven't seen any
problems with my testing.

graph_mutex is changed to a spinlock. Changed drivers that
directly hold the lock for graph walks.

media_entity_setup_link() might need to be made IRQ safe.
I am running more tests to ensure there is no lock warns
when dvb, video, and audio apps. run at the sametime and
use MC API (that holds graph_lock) to check for tuner
availability. Initial testing looked good so far.

2. Add enable_source handler field to struct media_device

Add a new field to enable handler to find source entity for the
sink entity and check if it is available, and activate the link
using media_entity_setup_link() interface. Bridge driver is
expected to implement and set the handler when media_device is
registered or when bridge driver finds the media_device during
probe. This is to enable the use-case to find tuner entity
connected to the decoder entity and check if it is available,
and activate the using media_entity_setup_link() if it is available.
This hanlder can be invoked from media core (v4l-core, dvb-core)
as well as other drivers such as ALSA that control the media device.

3. Changes to v4l2-core, ALSA to use enable_source handler

4. Changes to au0828 bridge driver to implement enable_source handler

Note: This series includes a revert to a patch that added media
controller entity framework enhancements that implemented entity
ops for entity_notify functionality. Entity ops for entity_notify
doesn't handle and cover entity create ordering variations that
could occur during boot. entity_notify list has been moved to media
device level which makes the entity_notify calls to work correctly.

History:
This patch series has been updated to address comments from
3 previous versions of this series. Links to v3 version
for reference are:

https://www.mail-archive.com/linux-media%40vger.kernel.org/msg89491.html
https://www.mail-archive.com/linux-media@vger.kernel.org/msg89492.html
https://www.mail-archive.com/linux-media%40vger.kernel.org/msg89493.html

Shuah Khan (19):
  Revert "[media] media: media controller entity framework enhancements
for ALSA"
  media: Media Controller register/unregister entity_notify API
  media: Add ALSA Media Controller devnodes
  media: au8522 change to create MC pad for ALSA Audio Out
  media: Convert graph_mutex to a spinlock and call it graph_lock
  media: platform exynos4-is: Update graph_mutex to graph_lock spinlock
  media: platform omap3isp: Update graph_mutex to graph_lock spinlock
  media: platform s3c-camif: Update graph_mutex to graph_lock spinlock
  media: platform vsp1: Update graph_mutex to graph_lock spinlock
  media: platform xilinx: Update graph_mutex to graph_lock spinlock
  staging media: davinci_vpfe: Update graph_mutex to graph_lock spinlock
  staging media: omap4iss: Update graph_mutex to graph_lock spinlock
  media: Add irq safe Media Controller start/stop pipeline API
  media: Add enable_source handler field to struct media_device
  media: v4l-core add v4l_enable_media_tuner() to check for tuner
availability
  media: Change v4l-core to check for tuner availability
  media: dvb-frontend change to check for tuner availability from open
  media: au0828 change to use Managed Media Controller API
  sound/usb: Update ALSA driver to use Managed Media Controller API

 drivers/media/dvb-core/dvb_frontend.c  |  43 ++--
 drivers/media/dvb-frontends/au8522.h   |   8 +
 drivers/media/dvb-frontends/au8522_decoder.c   |   1 +
 drivers/media/dvb-frontends/au8522_priv.h  |   8 -
 drivers/media/media-device.c   |  60 +-
 drivers/media/media-entity.c   |  88 ++--
 drivers/media/platform/exynos4-is/fimc-isp-video.c |   8 +-
 drivers/media/platform/exynos4-is/fimc-lite.c  |   8 +-
 drivers/media/platform/exynos4-is/media-dev.c  |  14 +-
 drivers/media/platform/exynos4-is/media-dev.h  |   4 +-
 drivers/media/platform/omap3isp/i

[PATCH v2 01/19] Revert "[media] media: media controller entity framework enhancements for ALSA"

2015-07-22 Thread Shuah Khan
This reverts commit ed64cf1e182fb30fe67652386c0880fcf3302f97.
This patch is no longer necessary as the entity register
callback is implemented at media_device level.

Signed-off-by: Shuah Khan 
---
 drivers/media/media-device.c | 7 ---
 include/media/media-entity.h | 4 
 2 files changed, 11 deletions(-)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 76590ba..c55ab50 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -428,8 +428,6 @@ EXPORT_SYMBOL_GPL(media_device_unregister);
 int __must_check media_device_register_entity(struct media_device *mdev,
  struct media_entity *entity)
 {
-   struct media_entity *eptr;
-
/* Warn if we apparently re-register an entity */
WARN_ON(entity->parent != NULL);
entity->parent = mdev;
@@ -442,11 +440,6 @@ int __must_check media_device_register_entity(struct 
media_device *mdev,
list_add_tail(&entity->list, &mdev->entities);
spin_unlock(&mdev->lock);
 
-   media_device_for_each_entity(eptr, mdev) {
-   if (eptr != entity)
-   media_entity_call(eptr, register_notify);
-   }
-
return 0;
 }
 EXPORT_SYMBOL_GPL(media_device_register_entity);
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 0bc4c2f..0c003d8 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -46,7 +46,6 @@ struct media_pad {
 
 /**
  * struct media_entity_operations - Media entity operations
- * @register_notifyNotify entity of newly registered entity
  * @link_setup:Notify the entity of link changes. The 
operation can
  * return an error, in which case link setup will be
  * cancelled. Optional.
@@ -55,7 +54,6 @@ struct media_pad {
  * validates all links by calling this operation. Optional.
  */
 struct media_entity_operations {
-   int (*register_notify)(struct media_entity *entity);
int (*link_setup)(struct media_entity *entity,
  const struct media_pad *local,
  const struct media_pad *remote, u32 flags);
@@ -103,8 +101,6 @@ struct media_entity {
/* Sub-device specifications */
/* Nothing needed yet */
} info;
-
-   void *private;  /* private data for the entity */
 };
 
 static inline u32 media_entity_type(struct media_entity *entity)
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 02/19] media: Media Controller register/unregister entity_notify API

2015-07-22 Thread Shuah Khan
Add new interfaces to register and unregister entity_notify
hook to media device to allow drivers to take appropriate
actions when as new entities get added to the shared media
device.When a new entity is registered, all registered
entity_notify hooks are invoked to allow drivers or modules
that registered hook to take appropriate action. For example,
ALSA driver registers an entity_notify hook to parse the list
of registered entities to determine if decoder has been linked
to ALSA entity. au0828 bridge driver registers an entity_notify
hook to create media graph for the device.

Signed-off-by: Shuah Khan 
---
 drivers/media/media-device.c | 45 
 include/media/media-device.h | 23 ++
 2 files changed, 68 insertions(+)

diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index c55ab50..22565a8 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -381,6 +381,7 @@ int __must_check __media_device_register(struct 
media_device *mdev,
 
mdev->entity_id = 1;
INIT_LIST_HEAD(&mdev->entities);
+   INIT_LIST_HEAD(&mdev->entity_notify);
spin_lock_init(&mdev->lock);
mutex_init(&mdev->graph_mutex);
 
@@ -411,9 +412,12 @@ void media_device_unregister(struct media_device *mdev)
 {
struct media_entity *entity;
struct media_entity *next;
+   struct media_entity_notify *notify, *nextp;
 
list_for_each_entry_safe(entity, next, &mdev->entities, list)
media_device_unregister_entity(entity);
+   list_for_each_entry_safe(notify, nextp, &mdev->entity_notify, list)
+   media_device_unregister_entity_notify(mdev, notify);
 
device_remove_file(&mdev->devnode.dev, &dev_attr_model);
media_devnode_unregister(&mdev->devnode);
@@ -421,6 +425,39 @@ void media_device_unregister(struct media_device *mdev)
 EXPORT_SYMBOL_GPL(media_device_unregister);
 
 /**
+ * media_device_register_entity_notify - Register a media entity notify
+ * callback with a media device. When a new entity is registered, all
+ * the registered media_entity_notify callbacks are invoked.
+ * @mdev:  The media device
+ * @nptr:  The media_entity_notify
+ */
+int __must_check media_device_register_entity_notify(struct media_device *mdev,
+   struct media_entity_notify *nptr)
+{
+   spin_lock(&mdev->lock);
+   list_add_tail(&nptr->list, &mdev->entity_notify);
+   spin_unlock(&mdev->lock);
+   return 0;
+}
+EXPORT_SYMBOL_GPL(media_device_register_entity_notify);
+
+/**
+ * media_device_unregister_entity_notify - Unregister a media entity notify
+ * callback with a media device. When a new entity is registered, all
+ * the registered media_entity_notify callbacks are invoked.
+ * @mdev:  The media device
+ * @nptr:  The media_entity_notify
+ */
+void media_device_unregister_entity_notify(struct media_device *mdev,
+   struct media_entity_notify *nptr)
+{
+   spin_lock(&mdev->lock);
+   list_del(&nptr->list);
+   spin_unlock(&mdev->lock);
+}
+EXPORT_SYMBOL_GPL(media_device_unregister_entity_notify);
+
+/**
  * media_device_register_entity - Register an entity with a media device
  * @mdev:  The media device
  * @entity:The entity
@@ -428,6 +465,8 @@ EXPORT_SYMBOL_GPL(media_device_unregister);
 int __must_check media_device_register_entity(struct media_device *mdev,
  struct media_entity *entity)
 {
+   struct media_entity_notify *notify, *next;
+
/* Warn if we apparently re-register an entity */
WARN_ON(entity->parent != NULL);
entity->parent = mdev;
@@ -440,6 +479,11 @@ int __must_check media_device_register_entity(struct 
media_device *mdev,
list_add_tail(&entity->list, &mdev->entities);
spin_unlock(&mdev->lock);
 
+   /* invoke entity_notify callbacks */
+   list_for_each_entry_safe(notify, next, &mdev->entity_notify, list) {
+   (notify)->notify(entity, notify->notify_data);
+   }
+
return 0;
 }
 EXPORT_SYMBOL_GPL(media_device_register_entity);
@@ -462,6 +506,7 @@ void media_device_unregister_entity(struct media_entity 
*entity)
list_del(&entity->list);
spin_unlock(&mdev->lock);
entity->parent = NULL;
+   /* invoke entity_notify callbacks to handle entity removal?? */
 }
 EXPORT_SYMBOL_GPL(media_device_unregister_entity);
 
diff --git a/include/media/media-device.h b/include/media/media-device.h
index a44f18f..a3854f6 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -32,6 +32,12 @@
 
 struct device;
 
+struct media_entity_notify {
+   struct list_head list;
+   void *notify_data;
+   void (*notify)(struct media_entity *entity, void *notify_data);
+};
+
 /**
  * struct media_device - Media device
  * @dev:   Parent device
@@ -70,6 +76,8 @@ st

Re: [PATCH 02/12] [media] dvb-pll: Add support for THOMSON DTT7546X tuner.

2015-07-22 Thread Mauro Carvalho Chehab
Em Wed, 24 Jun 2015 18:17:37 -0700
Joe Perches  escreveu:

> On Wed, 2015-06-24 at 16:11 +0100, Peter Griffin wrote:
> > This is used in conjunction with the STV0367 demodulator on
> > the STV0367-NIM-V1.0 NIM card which can be used with the STi
> > STB SoC's.
> 
> Barely associated to this specific patch, but for
> dvb-pll.c, another thing that seems possible is to
> convert the struct dvb_pll_desc uses to const and
> change the "entries" fixed array size from 12 to []
> 
> It'd save a couple KB overall and remove ~5KB of data.
> 
> $ size drivers/media/dvb-frontends/dvb-pll.o*
>text  data bss dec hex filename
>8520  15522120   121922fa0 
> drivers/media/dvb-frontends/dvb-pll.o.new
>5624  63632120   14107371b 
> drivers/media/dvb-frontends/dvb-pll.o.old

Peter,

Please add this patch on the next patch series you submit.

Regards,
Mauro

> ---
>  drivers/media/dvb-frontends/dvb-pll.c | 50 
> +--
>  1 file changed, 25 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/dvb-pll.c 
> b/drivers/media/dvb-frontends/dvb-pll.c
> index 6d8fe88..53089e1 100644
> --- a/drivers/media/dvb-frontends/dvb-pll.c
> +++ b/drivers/media/dvb-frontends/dvb-pll.c
> @@ -34,7 +34,7 @@ struct dvb_pll_priv {
>   struct i2c_adapter *i2c;
>  
>   /* the PLL descriptor */
> - struct dvb_pll_desc *pll_desc;
> + const struct dvb_pll_desc *pll_desc;
>  
>   /* cached frequency/bandwidth */
>   u32 frequency;
> @@ -57,7 +57,7 @@ MODULE_PARM_DESC(id, "force pll id to use (DEBUG ONLY)");
>  /* --- */
>  
>  struct dvb_pll_desc {
> - char *name;
> + const char *name;
>   u32  min;
>   u32  max;
>   u32  iffreq;
> @@ -71,13 +71,13 @@ struct dvb_pll_desc {
>   u32 stepsize;
>   u8  config;
>   u8  cb;
> - } entries[12];
> + } entries[];
>  };
>  
>  /* --- */
>  /* descriptions*/
>  
> -static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
> +static const struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
>   .name  = "Thomson dtt7579",
>   .min   = 17700,
>   .max   = 85800,
> @@ -99,7 +99,7 @@ static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 
> *buf)
>   buf[3] |= 0x10;
>  }
>  
> -static struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
> +static const struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
>   .name  = "Thomson dtt759x",
>   .min   = 17700,
>   .max   = 89600,
> @@ -123,7 +123,7 @@ static void thomson_dtt7520x_bw(struct dvb_frontend *fe, 
> u8 *buf)
>   buf[3] ^= 0x10;
>  }
>  
> -static struct dvb_pll_desc dvb_pll_thomson_dtt7520x = {
> +static const struct dvb_pll_desc dvb_pll_thomson_dtt7520x = {
>   .name  = "Thomson dtt7520x",
>   .min   = 18500,
>   .max   = 9,
> @@ -141,7 +141,7 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7520x = {
>   },
>  };
>  
> -static struct dvb_pll_desc dvb_pll_lg_z201 = {
> +static const struct dvb_pll_desc dvb_pll_lg_z201 = {
>   .name  = "LG z201",
>   .min   = 17400,
>   .max   = 86200,
> @@ -157,7 +157,7 @@ static struct dvb_pll_desc dvb_pll_lg_z201 = {
>   },
>  };
>  
> -static struct dvb_pll_desc dvb_pll_unknown_1 = {
> +static const struct dvb_pll_desc dvb_pll_unknown_1 = {
>   .name  = "unknown 1", /* used by dntv live dvb-t */
>   .min   = 17400,
>   .max   = 86200,
> @@ -179,7 +179,7 @@ static struct dvb_pll_desc dvb_pll_unknown_1 = {
>  /* Infineon TUA6010XS
>   * used in Thomson Cable Tuner
>   */
> -static struct dvb_pll_desc dvb_pll_tua6010xs = {
> +static const struct dvb_pll_desc dvb_pll_tua6010xs = {
>   .name  = "Infineon TUA6010XS",
>   .min   =  4425,
>   .max   = 85800,
> @@ -193,7 +193,7 @@ static struct dvb_pll_desc dvb_pll_tua6010xs = {
>  };
>  
>  /* Panasonic env57h1xd5 (some Philips PLL ?) */
> -static struct dvb_pll_desc dvb_pll_env57h1xd5 = {
> +static const struct dvb_pll_desc dvb_pll_env57h1xd5 = {
>   .name  = "Panasonic ENV57H1XD5",
>   .min   =  4425,
>   .max   = 85800,
> @@ -217,7 +217,7 @@ static void tda665x_bw(struct dvb_frontend *fe, u8 *buf)
>   buf[3] |= 0x08;
>  }
>  
> -static struct dvb_pll_desc dvb_pll_tda665x = {
> +static const struct dvb_pll_desc dvb_pll_tda665x = {
>   .name  = "Philips TDA6650/TDA6651",
>   .min   =  4425,
>   .max   = 85800,
> @@ -251,7 +251,7 @@ static void tua6034_bw(struct dvb_frontend *fe, u8 *buf)
>   buf[3] |= 0x08;
>  }
>  
> -static struct dvb_pll_desc dvb_pll_tua6034 = {
> +static const struct dvb_pll_desc dvb_pll_tua6034 = {
>   .name  = "Infineon TUA6034",
>   .min   =  4425,
>   .max   = 85800,
> @@ -275,7 +2

Re: [PATCH 11/12] [media] tsin: c8sectpfe: Add Kconfig and Makefile for the driver.

2015-07-22 Thread Mauro Carvalho Chehab
Em Wed, 24 Jun 2015 16:11:09 +0100
Peter Griffin  escreveu:

> This patch adds the Kconfig and Makefile for the c8sectpfe driver
> so it will be built. It also selects additional demodulator and tuners
> which are required by the supported NIM cards.
> 
> Signed-off-by: Peter Griffin 
> ---
>  drivers/media/Kconfig |  1 +
>  drivers/media/Makefile|  1 +
>  drivers/media/tsin/c8sectpfe/Kconfig  | 26 ++
>  drivers/media/tsin/c8sectpfe/Makefile | 11 +++
>  4 files changed, 39 insertions(+)
>  create mode 100644 drivers/media/tsin/c8sectpfe/Kconfig
>  create mode 100644 drivers/media/tsin/c8sectpfe/Makefile
> 
> diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
> index 1570992..82bc1dc 100644
> --- a/drivers/media/Kconfig
> +++ b/drivers/media/Kconfig
> @@ -170,6 +170,7 @@ source "drivers/media/pci/Kconfig"
>  source "drivers/media/platform/Kconfig"
>  source "drivers/media/mmc/Kconfig"
>  source "drivers/media/radio/Kconfig"
> +source "drivers/media/tsin/c8sectpfe/Kconfig"
>  
>  comment "Supported FireWire (IEEE 1394) Adapters"
>   depends on DVB_CORE && FIREWIRE
> diff --git a/drivers/media/Makefile b/drivers/media/Makefile
> index e608bbc..0a567b8 100644
> --- a/drivers/media/Makefile
> +++ b/drivers/media/Makefile
> @@ -29,5 +29,6 @@ obj-y += rc/
>  #
>  
>  obj-y += common/ platform/ pci/ usb/ mmc/ firewire/
> +obj-$(CONFIG_DVB_C8SECTPFE) += tsin/c8sectpfe/

Hmm... why are you adding it at a new "tsin" directory? We're putting
those SoC platform drivers under platform/.

>  obj-$(CONFIG_VIDEO_DEV) += radio/
>  
> diff --git a/drivers/media/tsin/c8sectpfe/Kconfig 
> b/drivers/media/tsin/c8sectpfe/Kconfig
> new file mode 100644
> index 000..8d99a87
> --- /dev/null
> +++ b/drivers/media/tsin/c8sectpfe/Kconfig
> @@ -0,0 +1,26 @@
> +config DVB_C8SECTPFE
> + tristate "STMicroelectronics C8SECTPFE DVB support"
> + depends on DVB_CORE && I2C && (ARCH_STI || ARCH_MULTIPLATFORM)
> + select DVB_LNBP21 if MEDIA_SUBDRV_AUTOSELECT
> + select DVB_STV090x if MEDIA_SUBDRV_AUTOSELECT
> + select DVB_STB6100 if MEDIA_SUBDRV_AUTOSELECT
> + select DVB_STV6110 if MEDIA_SUBDRV_AUTOSELECT
> + select DVB_STV0900 if MEDIA_SUBDRV_AUTOSELECT
> + select DVB_STV0367 if MEDIA_SUBDRV_AUTOSELECT
> + select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT
> + select MEDIA_TUNER_TDA18212 if MEDIA_SUBDRV_AUTOSELECT
> +
> + ---help---
> +   This adds support for DVB front-end cards connected
> +   to TS inputs of STiH407/410 SoC.
> +
> +   The driver currently supports C8SECTPFE's TS input block,
> +   memdma engine, and HW PID filtering.
> +
> +   Supported DVB front-end cards are:
> +   - STMicroelectronics DVB-T B2100A (STV0367 + TDA18212)
> +   - STMicroelectronics DVB-T STV0367 PLL board (STV0367 + DTT7546X)
> +   - STMicroelectronics DVB-S/S2 STV0903 + STV6110 + LNBP24 board
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called c8sectpfe.
> diff --git a/drivers/media/tsin/c8sectpfe/Makefile 
> b/drivers/media/tsin/c8sectpfe/Makefile
> new file mode 100644
> index 000..777f06d
> --- /dev/null
> +++ b/drivers/media/tsin/c8sectpfe/Makefile
> @@ -0,0 +1,11 @@
> +c8sectpfe-y += c8sectpfe-core.o c8sectpfe-common.o c8sectpfe-dvb.o
> +
> +obj-$(CONFIG_DVB_C8SECTPFE) += c8sectpfe.o
> +
> +ifneq ($(CONFIG_DVB_C8SECTPFE),)
> + c8sectpfe-y += c8sectpfe-debugfs.o
> +endif
> +
> +ccflags-y += -Idrivers/media/i2c
> +ccflags-y += -Idrivers/media/common
> +ccflags-y += -Idrivers/media/dvb-core/ -Idrivers/media/dvb-frontends/ 
> -Idrivers/media/tuners/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/12] [media] tsin: c8sectpfe: Add support for various ST NIM cards.

2015-07-22 Thread Mauro Carvalho Chehab
Em Wed, 24 Jun 2015 16:11:07 +0100
Peter Griffin  escreveu:

> This patch adds support for the following 3 NIM cards: -
> 1) STV0367-NIM (stv0367 demod with Thompson PLL)
> 2) B2100A (2x stv0367 demods & 2x NXP tda18212 tuners)
> 3) STV0903-6110NIM (stv0903 demod + 6110 tuner, lnb24)
> 
> Signed-off-by: Peter Griffin 
> ---
>  drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c | 296 
> +++
>  drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.h |  20 ++
>  2 files changed, 316 insertions(+)
>  create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c
>  create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.h
> 
> diff --git a/drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c 
> b/drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c
> new file mode 100644
> index 000..5c4ecb4
> --- /dev/null
> +++ b/drivers/media/tsin/c8sectpfe/c8sectpfe-dvb.c
> @@ -0,0 +1,296 @@
> +/*
> + *  c8sectpfe-dvb.c - C8SECTPFE STi DVB driver
> + *
> + * Copyright (c) STMicroelectronics 2015
> + *
> + *  Author Peter Griffin 
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *
> + *  GNU General Public License for more details.
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include "c8sectpfe-common.h"
> +#include "c8sectpfe-core.h"
> +#include "c8sectpfe-dvb.h"
> +
> +#include "dvb-pll.h"
> +#include "lnbh24.h"
> +#include "stv0367.h"
> +#include "stv0367_priv.h"
> +#include "stv6110x.h"
> +#include "stv090x.h"
> +#include "tda18212.h"
> +
> +static inline const char *dvb_card_str(unsigned int c)
> +{
> + switch (c) {
> + case STV0367_PLL_BOARD_NIMA:return "STV0367_PLL_BOARD_NIMA";
> + case STV0367_PLL_BOARD_NIMB:return "STV0367_PLL_BOARD_NIMB";
> + case STV0367_TDA18212_NIMA_1:   return "STV0367_TDA18212_NIMA_1";
> + case STV0367_TDA18212_NIMA_2:   return "STV0367_TDA18212_NIMA_2";
> + case STV0367_TDA18212_NIMB_1:   return "STV0367_TDA18212_NIMB_1";
> + case STV0367_TDA18212_NIMB_2:   return "STV0367_TDA18212_NIMB_2";
> + case STV0903_6110_LNB24_NIMA:   return "STV0903_6110_LNB24_NIMA";
> + case STV0903_6110_LNB24_NIMB:   return "STV0903_6110_LNB24_NIMB";
> + default:return "unknown dvb frontend card";
> + }
> +}
> +
> +static struct stv090x_config stv090x_config = {
> + .device = STV0903,
> + .demod_mode = STV090x_SINGLE,
> + .clk_mode   = STV090x_CLK_EXT,
> + .xtal   = 1600,
> + .address= 0x69,
> +
> + .ts1_mode   = STV090x_TSMODE_SERIAL_CONTINUOUS,
> + .ts2_mode   = STV090x_TSMODE_SERIAL_CONTINUOUS,
> +
> + .repeater_level = STV090x_RPTLEVEL_64,
> +
> + .tuner_init = NULL,
> + .tuner_set_mode = NULL,
> + .tuner_set_frequency= NULL,
> + .tuner_get_frequency= NULL,
> + .tuner_set_bandwidth= NULL,
> + .tuner_get_bandwidth= NULL,
> + .tuner_set_bbgain   = NULL,
> + .tuner_get_bbgain   = NULL,
> + .tuner_set_refclk   = NULL,
> + .tuner_get_status   = NULL,
> +};
> +
> +static struct stv6110x_config stv6110x_config = {
> + .addr   = 0x60,
> + .refclk = 1600,
> +};
> +
> +#define NIMA 0
> +#define NIMB 1
> +
> +static struct stv0367_config stv0367_pll_config[] = {
> + {
> + .demod_address = 0x1c,
> + .xtal = 2700,
> + .if_khz = 36166,
> + .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
> + .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
> + .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
> + }, {
> + .demod_address = 0x1d,
> + .xtal = 2700,
> + .if_khz = 36166,
> + .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
> + .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
> + .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
> + },
> +};
> +
> +static struct stv0367_config stv0367_tda18212_config[] = {
> + {
> + .demod_address = 0x1c,
> + .xtal = 1600,
> + .if_khz = 4500,
> + .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
> + .ts_mode = STV0367_SERIAL_PUNCT_CLOCK,
> + .clk_pol = STV0367_CLOCKPOLARITY_DEFAULT,
> + }, {
> + .demod_address = 0x1d,
> + .xtal = 1600,
> + .if_khz = 4500,
> + .if_iq_mode = FE_TER_NORMAL_IF_TUNER,
> + .ts_mode = STV0367_SERIA

Re: [PATCH 07/12] [media] tsin: c8sectpfe: STiH407/10 Linux DVB demux support

2015-07-22 Thread Mauro Carvalho Chehab
Em Wed, 24 Jun 2015 16:11:05 +0100
Peter Griffin  escreveu:

> This patch adds support for the c8sectpfe input HW found on
> STiH407/410 SoC's.
> 
> It currently supports the TS input block, memdma engine
> and hw PID filtering blocks of the C8SECTPFE subsystem.
> 
> The driver creates one LinuxDVB adapter, and a
> demux/dvr/frontend set of devices for each tsin channel
> which is specificed in the DT. It has been tested with
> multiple tsin channels tuned, locked, and grabbing TS
> simultaneously.
> 
> Signed-off-by: Peter Griffin 
> ---
>  drivers/media/tsin/c8sectpfe/c8sectpfe-core.c | 1105 
> +
>  drivers/media/tsin/c8sectpfe/c8sectpfe-core.h |  288 +++
>  2 files changed, 1393 insertions(+)
>  create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-core.c
>  create mode 100644 drivers/media/tsin/c8sectpfe/c8sectpfe-core.h
> 
> diff --git a/drivers/media/tsin/c8sectpfe/c8sectpfe-core.c 
> b/drivers/media/tsin/c8sectpfe/c8sectpfe-core.c
> new file mode 100644
> index 000..fbbe323
> --- /dev/null
> +++ b/drivers/media/tsin/c8sectpfe/c8sectpfe-core.c
> @@ -0,0 +1,1105 @@
> +/*
> + * c8sectpfe-core.c - C8SECTPFE STi DVB driver
> + *
> + * Copyright (c) STMicroelectronics 2015
> + *
> + *   Author:Peter Bennett 
> + *   Peter Griffin 
> + *
> + *   This program is free software; you can redistribute it and/or
> + *   modify it under the terms of the GNU General Public License as
> + *   published by the Free Software Foundation; either version 2 of
> + *   the License, or (at your option) any later version.
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "c8sectpfe-core.h"
> +#include "c8sectpfe-common.h"
> +#include "c8sectpfe-debugfs.h"
> +#include "dmxdev.h"
> +#include "dvb_demux.h"
> +#include "dvb_frontend.h"
> +#include "dvb_net.h"
> +
> +#define FIRMWARE_MEMDMA "pti_memdma_h407.elf"
> +MODULE_FIRMWARE(FIRMWARE_MEMDMA);
> +
> +#define PID_TABLE_SIZE 1024
> +#define POLL_20_HZ_DIV 20 /* poll at 20 Hz */
> +
> +static int load_slim_core_fw(struct c8sectpfei *fei);
> +
> +#define TS_PKT_SIZE 188
> +#define HEADER_SIZE (4)
> +#define PACKET_SIZE (TS_PKT_SIZE+HEADER_SIZE)
> +
> +#define FEI_ALIGNMENT (32)
> +/* hw requires minimum of 8*PACKET_SIZE and padded to 8byte boundary */
> +#define FEI_BUFFER_SIZE (8*PACKET_SIZE*340)
> +
> +#define FIFO_LEN 1024
> +
> +static void c8sectpfe_timer_interrupt(unsigned long ac8sectpfei)
> +{
> + struct c8sectpfei *fei = (struct c8sectpfei *)ac8sectpfei;
> + struct channel_info *channel;
> + int chan_num;
> +
> + /* iterate through input block channels */
> + for (chan_num = 0; chan_num < fei->tsin_count; chan_num++) {
> + channel = fei->channel_data[chan_num];
> +
> + /* is this descriptor initialised and TP enabled */
> + if (channel->irec && readl((void __iomem *)
> + &channel->irec->tp_enable))
> + tasklet_schedule(&channel->tsklet);
> + }
> +
> + fei->timer.expires = jiffies + (HZ / POLL_20_HZ_DIV);

Please use the macros for jiffies conversions. In this case, I guess
you want to use ms_to_jiffies(), right?

> + add_timer(&fei->timer);
> +}
> +
> +static void channel_swdemux_tsklet(unsigned long data)
> +{
> + struct channel_info *channel = (struct channel_info *)data;
> + struct c8sectpfei *fei = channel->fei;
> + struct tpentry *ptrblk;
> + unsigned long wp, rp;
> + int pos, num_packets, n, size;
> + u8 *buf;
> +
> + BUG_ON(!channel);
> + BUG_ON(!channel->irec);

Please avoid using BUG_ON() except when the machine will be on some
unstable state. In this case, I guess you could just do:

if (unlikely(!channel || !channel->irec)
return;

> +
> + ptrblk = &channel->irec->ptr_data[0];
> +
> + wp = readl((void __iomem *)&ptrblk->dma_bus_wp);
> + rp = readl((void __iomem *)&ptrblk->dma_bus_rp);

Why do you need those typecasts? We try to avoid typecasts in the Kernel,
doing it only where really needed. Same for other usages. You should
probably declare those DMA buffers as __iomem *, and avoid the casts.

> +
> + pos = rp - channel->back_buffer_busaddr;
> +
> + /* has it wrapped */
> + if (wp < rp)
> + wp = channel->back_buffer_busaddr + FEI_BUFFER_SIZE;
> +
> + size = wp - rp;
> + num_packets = size / PACKET_SIZE;
> +
> + /* manage cache so data is visible to CPU */
> + dma_sync_single_for_cpu(fei->dev,
> + rp,
> + size,
> + DMA_FROM_DEVICE);
> +
> + buf = (u8 *) channel->back_buffer_aligned;
> +
> + dev_dbg(fei->dev,
> + "chan=%d channel=%p num_pac

Re: [RFC] How to get current position/status of iris/focus/pan/tilt/zoom?

2015-07-22 Thread Sakari Ailus
Hi Hans,

On Wed, Jul 22, 2015 at 10:51:18AM +0200, Hans Verkuil wrote:
> On 07/22/15 10:21, Sakari Ailus wrote:
> > Hi Hans,
> > 
> > On Thu, Jul 02, 2015 at 02:00:23PM +0200, Hans Verkuil wrote:
> >> When using V4L2_CID_IRIS/FOCUS/PAN/TILT/ZOOM_ABSOLUTE/RELATIVE, how do you 
> >> know
> >> when the new position has been reached? If this is controlled through a 
> >> motor,
> >> then it may take some time and ideally you would like to be able to get the
> >> current absolute position (if the hardware knows) and whether the final 
> >> position
> >> has been reached or not.
> > 
> > On voice coil lenses it's also not possible to know when the position has
> > been reached, however you can estimate when it has happened based on the
> > intended movement and algorithm used to move the lens. This is far from
> > trivial though.
> > 
> > For low-level lends drivers knowing where the lens is is not feasible IMO at
> > the moment.
> > 
> >>
> >> In addition, it should be possible to raise fault conditions.
> > 
> > Do you know of hardware that can do this? The only non-buffer related
> > devices that can do this I'm aware of are flash controllers.
> 
> If a motor is involved to move things around, then that motor can cause
> failures that you want to signal. For example if something is blocking the
> motor from moving any further, overheating, whatever. I hate moving parts :-)

I don't argue about whether or not to tell it to the user, but can the
hardware tell that to the driver? If it can, naturally the user should be
told.

What I think would be nice to pay closer attention to at some point would be
voice coil lens controls. These are typically cheap and difficult to control
devices, as you apply a current that's going to move a lens rather than
telling it to be moved to a certain position. The higher level control is,
in my understanding, often more or less tightly coupled with the AF
algorithms. At the very least the existing drivers are quite low level
drivers. We should look what are the commonalities among those. But that'd
be a new topic likely requiring multiple RFCs...

This will quite probably look at least somewhat different in terms of
controls compared to current manual focus controls.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] rc-core: improve the lirc protocol reporting

2015-07-22 Thread David Härdeman
Commit 275ddb40bcf686d210d86c6718e42425a6a0bc76 removed the lirc
"protocol" but kept backwards compatibility by always listing
the protocol as present and enabled. This patch further improves
the logic by only listing the protocol if the lirc module is loaded
(or if lirc is builtin).

Signed-off-by: David Härdeman 
---
 drivers/media/rc/rc-main.c |   19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index ecaee02..3f0f71a 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -828,6 +828,23 @@ struct rc_filter_attribute {
.mask = (_mask),\
}
 
+static bool lirc_is_present(void)
+{
+#if defined(CONFIG_LIRC_MODULE)
+   struct module *lirc;
+
+   mutex_lock(&module_mutex);
+   lirc = find_module("lirc_dev");
+   mutex_unlock(&module_mutex);
+
+   return lirc ? true : false;
+#elif defined(CONFIG_LIRC)
+   return true;
+#else
+   return false;
+#endif
+}
+
 /**
  * show_protocols() - shows the current/wakeup IR protocol(s)
  * @device:the device descriptor
@@ -882,7 +899,7 @@ static ssize_t show_protocols(struct device *device,
allowed &= ~proto_names[i].type;
}
 
-   if (dev->driver_type == RC_DRIVER_IR_RAW)
+   if (dev->driver_type == RC_DRIVER_IR_RAW && lirc_is_present())
tmp += sprintf(tmp, "[lirc] ");
 
if (tmp != buf)

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Adding support for three new Hauppauge HVR-1275 variants - testers reqd.

2015-07-22 Thread Tycho Lürsen



Op 22-07-15 om 14:55 schreef Steven Toth:

On Wed, Jul 22, 2015 at 3:15 AM, Tycho Lürsen  wrote:

Hi Steven,
I'm happy to inform you that all failures have vanished.

Thanks.


Summarizing:
I compiled 4.2-RC3 with your patch and with

/* Tri-state the TS bus */
  si2168_set_ts_mode(fe, 0);

What happens if you revert this back to the code from my original
patch, and include your changes listed below?

IE:
/* Tri-state the TS bus */
si2168_set_ts_mode(fe, 1);

1) Do you still lock no signal lock issues.

MythTV  says 'no lock' (though I don't know if such a message is reliable)

2) Do you see normal video as you'd typically expect?

Nope, just a black screen.
Did not test it with TVheadend.
However, in MythTV (0.27.4) the line

si2168_set_ts_mode(fe, 0);

makes it work.


Thanks for helping! :)


You're welcome.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/12] [media] dvb-pll: Add support for THOMSON DTT7546X tuner.

2015-07-22 Thread Mauro Carvalho Chehab
Em Wed, 24 Jun 2015 16:11:00 +0100
Peter Griffin  escreveu:

> This is used in conjunction with the STV0367 demodulator on
> the STV0367-NIM-V1.0 NIM card which can be used with the STi
> STB SoC's.
> 
> This tuner has a fifth register, so some changes have been made
> to accommodate this.
> 
> Signed-off-by: Peter Griffin 
> ---
>  drivers/media/dvb-frontends/dvb-pll.c | 74 
> +--
>  drivers/media/dvb-frontends/dvb-pll.h |  1 +
>  2 files changed, 64 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/dvb-pll.c 
> b/drivers/media/dvb-frontends/dvb-pll.c
> index 6d8fe88..f7381c7 100644
> --- a/drivers/media/dvb-frontends/dvb-pll.c
> +++ b/drivers/media/dvb-frontends/dvb-pll.c
> @@ -141,6 +141,35 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7520x = {
>   },
>  };
>  
> +static void thomson_dtt7546x_bw(struct dvb_frontend *fe, u8 *buf)
> +{
> + /* set CB2 reg - set ATC, XTO */
> + buf[4] = 0xc3;
> +}
> +
> +static struct dvb_pll_desc dvb_pll_thomson_dtt7546x = {
> + .name  = "Thomson dtt7546x",
> + .min   = 4425,
> + .max   = 86325,
> + .set   = thomson_dtt7546x_bw,
> + .iffreq= 3617,

Whitespace is missing. Please check the patchs with scripts/checkpatch.pl.

> + .count = 12,
> + .entries = {
> + {  12100, 17, 0x88, 0x01 },
> + {  14100, 17, 0x88, 0x41 },
> + {  16600, 17, 0x88, 0x81 },
> + {  18200, 17, 0x88, 0xc1 },
> + {  28600, 17, 0x88, 0x02 },
> + {  38600, 17, 0x88, 0x42 },
> + {  44600, 17, 0x88, 0x82 },
> + {  46600, 17, 0x88, 0xc2 },
> + {  50600, 17, 0x88, 0x08 },
> + {  76100, 17, 0x88, 0x48 },
> + {  84600, 17, 0x88, 0x88 },
> + {  90500, 17, 0x88, 0xc8 },
> + },
> +};
> +
>  static struct dvb_pll_desc dvb_pll_lg_z201 = {
>   .name  = "LG z201",
>   .min   = 17400,
> @@ -537,6 +566,7 @@ static struct dvb_pll_desc dvb_pll_alps_tdee4 = {
>  static struct dvb_pll_desc *pll_list[] = {
>   [DVB_PLL_UNDEFINED]  = NULL,
>   [DVB_PLL_THOMSON_DTT7579]= &dvb_pll_thomson_dtt7579,
> + [DVB_PLL_THOMSON_DTT7546X]   = &dvb_pll_thomson_dtt7546x,
>   [DVB_PLL_THOMSON_DTT759X]= &dvb_pll_thomson_dtt759x,
>   [DVB_PLL_THOMSON_DTT7520X]   = &dvb_pll_thomson_dtt7520x,
>   [DVB_PLL_LG_Z201]= &dvb_pll_lg_z201,
> @@ -561,7 +591,7 @@ static struct dvb_pll_desc *pll_list[] = {
>  /* code*/
>  
>  static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf,
> -  const u32 frequency)
> + const u32 frequency, const u32 len)
>  {
>   struct dvb_pll_priv *priv = fe->tuner_priv;
>   struct dvb_pll_desc *desc = priv->pll_desc;
> @@ -593,11 +623,15 @@ static int dvb_pll_configure(struct dvb_frontend *fe, 
> u8 *buf,
>   if (desc->set)
>   desc->set(fe, buf);
>  
> - if (debug)
> - printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
> -desc->name, div, buf[0], buf[1], buf[2], buf[3]);
> + if (debug) {
> + printk(KERN_DEBUG "pll: %s: div=%d | buf=", desc->name, div);
> + for (i = 0; i < len; i++)
> + printk(KERN_DEBUG "0x%02x,", buf[i]);
>  
> - // calculate the frequency we set it to
> + printk(KERN_DEBUG "\n");
> + }

Please use, instead, the Documentation/printk-formats.txt macros to
print an hex buffer:

"Raw buffer as a hex string:
%*ph00 01 02  ...  3f
%*phC   00:01:02: ... :3f
%*phD   00-01-02- ... -3f
%*phN   000102 ... 3f"


> +
> + /* calculate the frequency we set it to */
>   return (div * desc->entries[i].stepsize) - desc->iffreq;
>  }
>  
> @@ -634,21 +668,39 @@ static int dvb_pll_sleep(struct dvb_frontend *fe)
>   return -EINVAL;
>  }
>  
> +static int dvb_pll_get_num_regs(struct dvb_pll_priv *priv)
> +{
> + int num_regs = 4;
> +
> + if (strncmp(priv->pll_desc->name, "Thomson dtt7546x", 16) == 0)
> + num_regs = 5;
> +
> + return num_regs;
> +}
> +
>  static int dvb_pll_set_params(struct dvb_frontend *fe)
>  {
>   struct dtv_frontend_properties *c = &fe->dtv_property_cache;
>   struct dvb_pll_priv *priv = fe->tuner_priv;
> - u8 buf[4];
> - struct i2c_msg msg =
> - { .addr = priv->pll_i2c_address, .flags = 0,
> -   .buf = buf, .len = sizeof(buf) };
> + struct i2c_msg msg;
> + u8 *bufp;
>   int result;
>   u32 frequency = 0;
>  
> + bufp = kzalloc(dvb_pll_get_num_regs(priv), GFP_KERNEL);
> +
> + if (!bufp)
> + return -ENOMEM;
> +
> + msg.addr = priv->pll_i2c_

[PATCH 1/1] v4l: subdev: Serialise open and release internal ops

2015-07-22 Thread Sakari Ailus
By default, serialise open and release internal ops using a mutex.

The underlying problem is that a large proportion of the drivers do use
v4l2_fh_is_singular() in their open() handlers (struct
v4l2_subdev_internal_ops). v4l2_subdev_open(), .open file operation handler
of the V4L2 sub-device framework, calls v4l2_fh_add() which adds the file
handle to the list of open file handles of the device. Later on in the
open() handler of the sub-device driver uses v4l2_fh_is_singular() to
determine whether it was the file handle which was first opened. The check
may go wrong if the device was opened by multiple process closely enough in
time.

Why this is especially important is because many drivers perform power
management and other hardware initialisation based on open file handles.

Example one: Two processes open the device, but both end up determining
neither was the first file handle opened on the device.

process A: v4l2_fh_add()
process B: v4l2_fh_add()

...

process A: v4l2_fh_is_singular() # false
process B: v4l2_fh_is_singular() # false

Example two:

process A: v4l2_fh_add()

...

process A: v4l2_fh_is_singular() # true
 # at this point the driver does
 # time-consuming hardware
 # initialisation in the context of
 # process A

process B: v4l2_fh_add()
process B: v4l2_fh_is_singular() # false
 # open system call finishes

...

process B proceeds to access the sub-device

...

process A finishes hardware initialisation

If the sub-device's open() handler in struct v4l2_subdev_internal_ops is not
defined, then the information on whether the file handle was the first to be
opened is not needed to complete the open system call on the device, and
serialisation of the open and release system calls thus is not needed, with
the possible exception for the driver's own reasons, but that is entirely
the job of the driver.

Signed-off-by: Sakari Ailus 
---
 drivers/media/v4l2-core/v4l2-device.c |  4 
 drivers/media/v4l2-core/v4l2-subdev.c | 41 +--
 include/media/v4l2-subdev.h   |  4 
 3 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-device.c 
b/drivers/media/v4l2-core/v4l2-device.c
index 5b0a30b..a13e0be 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -191,6 +191,8 @@ int v4l2_device_register_subdev(struct v4l2_device 
*v4l2_dev,
}
 #endif
 
+   mutex_init(&sd->open_lock);
+
spin_lock(&v4l2_dev->lock);
list_add_tail(&sd->list, &v4l2_dev->subdevs);
spin_unlock(&v4l2_dev->lock);
@@ -292,5 +294,7 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd)
video_unregister_device(sd->devnode);
if (!sd->owner_v4l2_dev)
module_put(sd->owner);
+
+   mutex_destroy(&sd->open_lock);
 }
 EXPORT_SYMBOL_GPL(v4l2_device_unregister_subdev);
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c 
b/drivers/media/v4l2-core/v4l2-subdev.c
index b3f7da9..d8a98c4 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -50,6 +50,18 @@ static void subdev_fh_free(struct v4l2_subdev_fh *fh)
 #endif
 }
 
+static void subdev_open_lock(struct v4l2_subdev *sd)
+{
+   if (sd->flags & V4L2_SUBDEV_FL_SERIALISE_OPEN)
+   mutex_lock(&sd->open_lock);
+}
+
+static void subdev_open_unlock(struct v4l2_subdev *sd)
+{
+   if (sd->flags & V4L2_SUBDEV_FL_SERIALISE_OPEN)
+   mutex_unlock(&sd->open_lock);
+}
+
 static int subdev_open(struct file *file)
 {
struct video_device *vdev = video_devdata(file);
@@ -64,11 +76,11 @@ static int subdev_open(struct file *file)
if (subdev_fh == NULL)
return -ENOMEM;
 
+   subdev_open_lock(sd);
+
ret = subdev_fh_init(subdev_fh, sd);
-   if (ret) {
-   kfree(subdev_fh);
-   return ret;
-   }
+   if (ret)
+   goto err_free_subdev_fh;
 
v4l2_fh_init(&subdev_fh->vfh, vdev);
v4l2_fh_add(&subdev_fh->vfh);
@@ -78,7 +90,7 @@ static int subdev_open(struct file *file)
entity = media_entity_get(&sd->entity);
if (!entity) {
ret = -EBUSY;
-   goto err;
+   goto err_media_entity_put;
}
}
 #endif
@@ -86,20 +98,26 @@ static int subdev_open(struct file *file)
if (sd->internal_ops && sd->internal_ops->open) {
ret = sd->internal_ops->open(sd, subdev_fh);
if (ret < 0)
-   goto err;
+   goto err_media_entity_put;
}
 
+   subdev_open_unlock(sd

Re: Adding support for three new Hauppauge HVR-1275 variants - testers reqd.

2015-07-22 Thread Steven Toth
On Wed, Jul 22, 2015 at 3:15 AM, Tycho Lürsen  wrote:
> Hi Steven,
> I'm happy to inform you that all failures have vanished.

Thanks.

>
> Summarizing:
> I compiled 4.2-RC3 with your patch and with
>
> /* Tri-state the TS bus */
>  si2168_set_ts_mode(fe, 0);

What happens if you revert this back to the code from my original
patch, and include your changes listed below?

IE:
   /* Tri-state the TS bus */
   si2168_set_ts_mode(fe, 1);

1) Do you still lock no signal lock issues.
2) Do you see normal video as you'd typically expect?

Thanks for helping! :)

-- 
Steven Toth - Kernel Labs
http://www.kernellabs.com
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/3] devicetree: bindings: Document Renesas R-Car JPEG Processing Unit

2015-07-22 Thread Mikhail Ulyanov
Add Renesas R-Car JPEG processing unit driver device tree bindings 
documentation.

Signed-off-by: Mikhail Ulyanov 
---
Changes since v2:
 - remove generic "renesas,jpu-gen2" descriptor

Changes since v1:
 - Fix typos

 .../devicetree/bindings/media/renesas,jpu.txt  | 24 ++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,jpu.txt

diff --git a/Documentation/devicetree/bindings/media/renesas,jpu.txt 
b/Documentation/devicetree/bindings/media/renesas,jpu.txt
new file mode 100644
index 000..0cb9420
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/renesas,jpu.txt
@@ -0,0 +1,24 @@
+* Renesas JPEG Processing Unit
+
+The JPEG processing unit (JPU) incorporates the JPEG codec with an encoding
+and decoding function conforming to the JPEG baseline process, so that the JPU
+can encode image data and decode JPEG data quickly.
+
+Required properties:
+  - compatible: should containg one of the following:
+   - "renesas,jpu-r8a7790" for R-Car H2
+   - "renesas,jpu-r8a7791" for R-Car M2-W
+   - "renesas,jpu-r8a7792" for R-Car V2H
+   - "renesas,jpu-r8a7793" for R-Car M2-N
+
+  - reg: Base address and length of the registers block for the JPU.
+  - interrupts: JPU interrupt specifier.
+  - clocks: A phandle + clock-specifier pair for the JPU functional clock.
+
+Example: R8A7790 (R-Car H2) JPU node
+   jpeg-codec@fe98 {
+   compatible = "renesas,jpu-r8a7790";
+   reg = <0 0xfe98 0 0x10300>;
+   interrupts = <0 272 IRQ_TYPE_LEVEL_HIGH>;
+   clocks = <&mstp1_clks R8A7790_CLK_JPU>;
+   };
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] MAINTAINERS: V4L2: PLATFORM: Add entry for Renesas JPEG Processing Unit driver

2015-07-22 Thread Mikhail Ulyanov
Update RENESAS JPU driver maintainer in MAINTAINERS file.

Signed-off-by: Mikhail Ulyanov 
---
 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index b65b22b..da57ec1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5381,6 +5381,12 @@ S:   Maintained
 F: fs/jbd2/
 F: include/linux/jbd2.h
 
+JPU V4L2 MEM2MEM DRIVER FOR RENESAS
+M: Mikhail Ulyanov 
+L: linux-media@vger.kernel.org
+S: Maintained
+F: drivers/media/platform/rcar_jpu.c
+
 JSM Neo PCI based serial card
 M: Thadeu Lima de Souza Cascardo 
 L: linux-ser...@vger.kernel.org
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 1/3] V4L2: platform: Add Renesas R-Car JPEG codec driver

2015-07-22 Thread Mikhail Ulyanov
Here's the driver for the Renesas R-Car JPEG processing unit.

The driver is implemented within the V4L2 framework as a memory-to-memory
device.  It presents two video nodes to userspace, one for the encoding part,
and one for the decoding part.

It was found that the only working mode for encoding is no markers output, so we
generate markers with software. In the current version of driver we also use
software JPEG header parsing because with hardware parsing performance is lower
than desired.

>From a userspace point of view the process is typical (S_FMT, REQBUF,
optionally QUERYBUF, QBUF, STREAMON, DQBUF) for both the source and destination
queues. STREAMON can return -EINVAL in case of mismatch of output and capture
queues format. Also during decoding driver can return buffers if queued
buffer with JPEG image contains image with inappropriate subsampling (e.g.
4:2:0 in JPEG and 4:2:2 in capture).  If JPEG image and queue format dimensions
differ driver will return buffer on QBUF with VB2_BUF_STATE_ERROR flag.

During encoding the available formats are: V4L2_PIX_FMT_NV12M,
V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_NV16, V4L2_PIX_FMT_NV16M for source and
V4L2_PIX_FMT_JPEG for destination.

During decoding the available formats are: V4L2_PIX_FMT_JPEG for source and
V4L2_PIX_FMT_NV12M, V4L2_PIX_FMT_NV16M, V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_NV16
for destination.

Performance of current version:
1280x800 NV12 image encoding/decoding
decoding ~122 FPS
encoding ~191 FPS

Signed-off-by: Mikhail Ulyanov 
---
 Changes since v5:
- VIDIOC_CREATE_BUFS support added(m2m helper and jpu_queue_setup fix)
- VIDIOC_EXPBUF support added(m2m helper)

 Changes since v4:
- ARCH dependency added to Kconfig
- module name fix in Kconfig
- add v4l2_buf.sequence number filling
- add v4l2_buf.field copy from source to destination buffer
- only valid flags in destination buffer
- fix bpl type in __jpu_try_fmt()
- remove V4L2_MEMORY_USERPTR support as almost useless and buggy
- fix jpu->curr setup in irq handler

 Changes since v3:
- driver file renamed to rcar_jpu.c
- semiplanar formats NV12 and NV16 support
- new callbacks streamon, job_abort and stop_streaming
- extra processing error information printout irq handler
- fill in JPEG header for encoded buffer in buf_finish
- wrapped reading/writing to registers
- vb2_set_plane_payload only for necessary buffer in buf_prepare
- multiple buffers now supported
- removed format setup with parsed info; rely only on users info
- JPEG header parser redesigned
- video_device structs embedded
- video_device_alloc/release removed
- "name" filed in format description removed
- remove g_selection
- start_streaming removed

Changes since v2:
- Kconfig entry reordered
- unnecessary clk_disable_unprepare(jpu->clk) removed
- ref_count fixed in jpu_resume
- enable DMABUF in src_vq->io_modes
- remove jpu_s_priority jpu_g_priority
- jpu_g_selection fixed
- timeout in jpu_reset added and hardware reset reworked
- remove unused macros
- JPEG header parsing now is software because of performance issues
  based on s5p-jpeg code
- JPEG header generation redesigned:
  JPEG header(s) pre-generated and memcpy'ed on encoding
  we only fill the necessary fields
  more "transparent" header format description
- S_FMT, G_FMT and TRY_FMT hooks redesigned
  partially inspired by VSP1 driver code
- some code was reformatted
- image formats handling redesigned
- multi-planar V4L2 API now in use
- now passes v4l2-compliance tool check

Cnanges since v1:
- s/g_fmt function simplified
- default format for queues added
- dumb vidioc functions added to be in compliance with standard api:
jpu_s_priority, jpu_g_priority
- standard v4l2_ctrl_subscribe_event and v4l2_event_unsubscribe
  now in use by the same reason

 drivers/media/platform/Kconfig|   12 +
 drivers/media/platform/Makefile   |1 +
 drivers/media/platform/rcar_jpu.c | 1794 +
 3 files changed, 1807 insertions(+)
 create mode 100644 drivers/media/platform/rcar_jpu.c

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index f6bed19..ea1cb83 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -231,6 +231,18 @@ config VIDEO_SH_VEU
Support for the Video Engine Unit (VEU) on SuperH and
SH-Mobile SoCs.
 
+config VIDEO_RENESAS_JPU
+   tristate "Renesas JPEG Processing Unit"
+   depends on VIDEO_DEV && VIDEO_V4L2
+   depends on ARCH_SHMOBILE || COMPILE_TEST
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_MEM2MEM_DEV
+   ---help---
+ This is a V4L2 driver for the Renesas JPEG Processing Unit.
+
+ To compile this driver as a module, choose M here: the module
+ will be called rcar_jpu.
+
 config VID

[PATCH 0/3] R-Car JPEG Processing Unit

2015-07-22 Thread Mikhail Ulyanov
This series of patches contains a driver for the JPEG codec integrated
peripheral found in the Renesas R-Car SoCs and associated DT documentation.

This series of patches is against the 'master' branch of
linuxtv.org/media_tree.git

v4l2-compliance -s

Driver Info:
Driver name   : rcar_jpu
Card type : rcar_jpu encoder
Bus info  : platform:fe98.jpu
Driver version: 4.2.0
Capabilities  : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK

Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK
test VIDIOC_LOG_STATUS: OK (Not Supported)

Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0

Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)

Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 2 Private Controls: 0

Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK

Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK

Test input 0:

Streaming ioctls:
test read/write: OK (Not Supported)
test MMAP: OK
test USERPTR: OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device


Total: 45, Succeeded: 45, Failed: 0, Warnings: 0

Mikhail Ulyanov (3):
  V4L2: platform: Add Renesas R-Car JPEG codec driver.
  devicetree: bindings: Document Renesas JPEG Processing Unit
  MAINTAINERS: V4L2: PLATFORM: Add entry for Renesas JPEG Processing
Unit driver

 .../devicetree/bindings/media/renesas,jpu.txt  |   24 +
 MAINTAINERS|6 +
 drivers/media/platform/Kconfig |   12 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/rcar_jpu.c  | 1794 
 5 files changed, 1837 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/renesas,jpu.txt
 create mode 100644 drivers/media/platform/rcar_jpu.c

--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] How to get current position/status of iris/focus/pan/tilt/zoom?

2015-07-22 Thread Hans Verkuil
On 07/22/15 10:21, Sakari Ailus wrote:
> Hi Hans,
> 
> On Thu, Jul 02, 2015 at 02:00:23PM +0200, Hans Verkuil wrote:
>> When using V4L2_CID_IRIS/FOCUS/PAN/TILT/ZOOM_ABSOLUTE/RELATIVE, how do you 
>> know
>> when the new position has been reached? If this is controlled through a 
>> motor,
>> then it may take some time and ideally you would like to be able to get the
>> current absolute position (if the hardware knows) and whether the final 
>> position
>> has been reached or not.
> 
> On voice coil lenses it's also not possible to know when the position has
> been reached, however you can estimate when it has happened based on the
> intended movement and algorithm used to move the lens. This is far from
> trivial though.
> 
> For low-level lends drivers knowing where the lens is is not feasible IMO at
> the moment.
> 
>>
>> In addition, it should be possible to raise fault conditions.
> 
> Do you know of hardware that can do this? The only non-buffer related
> devices that can do this I'm aware of are flash controllers.

If a motor is involved to move things around, then that motor can cause
failures that you want to signal. For example if something is blocking the
motor from moving any further, overheating, whatever. I hate moving parts :-)

> I'd only define them if there's actual hardware that can actually raise
> these conditions.
> 
>>
>> The way the ABSOLUTE controls are defined is ambiguous since it doesn't say
>> anything about what it returns when you read it: is that the current absolute
>> position, or the last set absolute position? I suspect it is the second one.
> 
> I wonder if this has been really well thought out when the controls were
> defined. I share your assumption.
> 
>> If it is the second one, then I propose a V4L2_CID_IRIS_CURRENT control (and
>> ditto for the other variants) that is a read-only control returning the 
>> current
>> position with the same range and unit as the ABSOLUTE control.
> 
> This makes perfect sense if you have hardware that can tell the current
> position.
> 
> Only one of the RELATIVE and ABSOLUTE controls should be implemented. I
> guess no driver in mainline would implement both,

That makes sense.

> I've seen such outside
> mainline though. :-)
> 
>>
>> For the status/fault information I think the V4L2_CID_AUTO_FOCUS_STATUS comes
>> close, but it is too specific for auto focus. For manually positioning things
>> this might be more suitable:
>>
>> V4L2_CID_IRIS_STATUS bitmask
>>
>>  V4L2_IRIS_STATUS_MOVING (or perhaps _BUSY?)
>>  V4L2_IRIS_STATUS_FAILED
>>
>> And ditto for the other variants.
> 
> If you have hardware that can give you the information, sure.
> 
>> Interaction between V4L2_CID_FOCUS_STATUS and AUTO_FOCUS_STATUS:
>>
>> If auto focus is enabled, then FOCUS_STATUS is always 0, if auto focus is
>> disabled, then AUTO_FOCUS_STATUS is always IDLE.
> 
> Looks good to me.
> 

Thanks!

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC] How to get current position/status of iris/focus/pan/tilt/zoom?

2015-07-22 Thread Sakari Ailus
Hi Hans,

On Thu, Jul 02, 2015 at 02:00:23PM +0200, Hans Verkuil wrote:
> When using V4L2_CID_IRIS/FOCUS/PAN/TILT/ZOOM_ABSOLUTE/RELATIVE, how do you 
> know
> when the new position has been reached? If this is controlled through a motor,
> then it may take some time and ideally you would like to be able to get the
> current absolute position (if the hardware knows) and whether the final 
> position
> has been reached or not.

On voice coil lenses it's also not possible to know when the position has
been reached, however you can estimate when it has happened based on the
intended movement and algorithm used to move the lens. This is far from
trivial though.

For low-level lends drivers knowing where the lens is is not feasible IMO at
the moment.

> 
> In addition, it should be possible to raise fault conditions.

Do you know of hardware that can do this? The only non-buffer related
devices that can do this I'm aware of are flash controllers.

I'd only define them if there's actual hardware that can actually raise
these conditions.

> 
> The way the ABSOLUTE controls are defined is ambiguous since it doesn't say
> anything about what it returns when you read it: is that the current absolute
> position, or the last set absolute position? I suspect it is the second one.

I wonder if this has been really well thought out when the controls were
defined. I share your assumption.

> If it is the second one, then I propose a V4L2_CID_IRIS_CURRENT control (and
> ditto for the other variants) that is a read-only control returning the 
> current
> position with the same range and unit as the ABSOLUTE control.

This makes perfect sense if you have hardware that can tell the current
position.

Only one of the RELATIVE and ABSOLUTE controls should be implemented. I
guess no driver in mainline would implement both, I've seen such outside
mainline though. :-)

> 
> For the status/fault information I think the V4L2_CID_AUTO_FOCUS_STATUS comes
> close, but it is too specific for auto focus. For manually positioning things
> this might be more suitable:
> 
> V4L2_CID_IRIS_STATUS  bitmask
> 
>   V4L2_IRIS_STATUS_MOVING (or perhaps _BUSY?)
>   V4L2_IRIS_STATUS_FAILED
> 
> And ditto for the other variants.

If you have hardware that can give you the information, sure.

> Interaction between V4L2_CID_FOCUS_STATUS and AUTO_FOCUS_STATUS:
> 
> If auto focus is enabled, then FOCUS_STATUS is always 0, if auto focus is
> disabled, then AUTO_FOCUS_STATUS is always IDLE.

Looks good to me.

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 11/12] [media] tsin: c8sectpfe: Add Kconfig and Makefile for the driver.

2015-07-22 Thread Peter Griffin
Hi Paul,

Thanks for reviewing.

On Thu, 25 Jun 2015, Paul Bolle wrote:

> On Wed, 2015-06-24 at 16:11 +0100, Peter Griffin wrote:
> > --- /dev/null
> > +++ b/drivers/media/tsin/c8sectpfe/Makefile
> 
> > +c8sectpfe-y += c8sectpfe-core.o c8sectpfe-common.o c8sectpfe-dvb.o
> > +
> > +obj-$(CONFIG_DVB_C8SECTPFE) += c8sectpfe.o
> > +
> > +ifneq ($(CONFIG_DVB_C8SECTPFE),)
> > +   c8sectpfe-y += c8sectpfe-debugfs.o
> > +endif
> 
> Isn't the above equivalent to
> c8sectpfe-y += c8sectpfe-core.o c8sectpfe-common.o c8sectpfe-dvb.o 
> c8sectpfe-debugfs.o
> 
> obj-$(CONFIG_DVB_C8SECTPFE) += c8sectpfe.o
> 
> Or am I missing something subtle here?

No I think I just messed up. Will fix in v2.

I suspect what happened  was I was starting to add a 
CONFIG_DVB_C8SECTPFE_DEBUGFS
Kconfig option, and then forgot ;)

In v2 I have added a "select DEBUG_FS" to Kconfig for the driver, and put it 
all on one
line. Also at the same time fixing some other Kconfig dependencies I noticed so
it now has 'select LIBELF_32' and 'select FW_LOADER'.

regards,

Peter.


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Adding support for three new Hauppauge HVR-1275 variants - testers reqd.

2015-07-22 Thread Tycho Lürsen

Hi Steven,
I'm happy to inform you that all failures have vanished.

Summarizing:
I compiled 4.2-RC3 with your patch and with

/* Tri-state the TS bus */
 si2168_set_ts_mode(fe, 0);

changed the .delsys line in si2168.c to satisfy MythTV from

.delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A},

to

.delsys = {SYS_DVBC_ANNEX_A, SYS_DVBT, SYS_DVBT2},

added the dvbloopback module (for descrambling with MythTV) and saa716x 
bridge driver (to support my TBS 6285 cards)


Result: lock and tune is just fine in both TVheadend and MythTV with TBS 
6285 as well as DVBSky T982 cards.


TBS 6285: saa716x+si2168+si2157
DVBSky T982: cx23885+si2168+si2157

Regards,
Tycho.

Op 21-07-15 om 21:00 schreef Steven Toth:

On Tue, Jul 21, 2015 at 2:07 PM, Tycho Lürsen  wrote:


Op 21-07-15 om 18:19 schreef Steven Toth:

On Tue, Jul 21, 2015 at 12:11 PM, Tycho Lürsen 
wrote:

Hi Steven,
I was too curious to wait for you and Antti to settle your differences,
so I
tested again against a 4.2-RC2
I did not disable DVB-T/T2, instead I reordered the lot. MythTV just sees
the first system in the .delsys line in si2168.c,
so when it looks like this:
SYS_DVBC_ANNEX_A, SYS_DVBT, SYS_DVBT2
I'm good.

We have no differences, its Antti's si2168 driver. If Antti doesn't
like the approach for tri-stating, he's free to suggest and
alternative. I suggested two alternatives yesterday.


Result:
With your patch both MythTV and Tvheadend still can't tune. Without it,
everything is ok.

I'm not very interested in czap results, only in real use cases. For me
that's MythTV, but just to be sure I also tested with TVheadend.

That's pretty bizarre results, although thank you for testing. :)

When you say it can't tune, do you mean the signal does not lock, or
that no video appears?


No lock, or partial lock.

Thanks.

That's even worse than expected, given that the patch adjusts the TS
interface, and has nothing to do with tuning, lock, rf or signal
status. It still feels like something else is going on, some other
unexpected race for example.

I can't reproduce that behavior, but given that you can Can you
please try this? in si2168.c, change:

  /* Tri-state the TS bus */
  si2168_set_ts_mode(fe, 1);

to

  /* Tri-state the TS bus */
  si2168_set_ts_mode(fe, 0);

... recompile and retest?

Thx.



--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html