Merge tag 'v5.2-rc4' into media/master
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 11 Jun 2019 16:09:28 +0000 (12:09 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 11 Jun 2019 16:09:28 +0000 (12:09 -0400)
There are some conflicts due to SPDX changes. We also have more
patches being merged via media tree touching them.

So, let's merge back from upstream and address those.

Linux 5.2-rc4

* tag 'v5.2-rc4': (767 commits)
  Linux 5.2-rc4
  MAINTAINERS: Karthikeyan Ramasubramanian is MIA
  i2c: xiic: Add max_read_len quirk
  lockref: Limit number of cmpxchg loop retries
  uaccess: add noop untagged_addr definition
  x86/insn-eval: Fix use-after-free access to LDT entry
  kbuild: use more portable 'command -v' for cc-cross-prefix
  s390/unwind: correct stack switching during unwind
  block, bfq: add weight symlink to the bfq.weight cgroup parameter
  cgroup: let a symlink too be created with a cftype file
  drm/nouveau/secboot/gp10[2467]: support newer FW to fix SEC2 failures on some boards
  drm/nouveau/secboot: enable loading of versioned LS PMU/SEC2 ACR msgqueue FW
  drm/nouveau/secboot: split out FW version-specific LS function pointers
  drm/nouveau/secboot: pass max supported FW version to LS load funcs
  drm/nouveau/core: support versioned firmware loading
  drm/nouveau/core: pass subdev into nvkm_firmware_get, rather than device
  block: free sched's request pool in blk_cleanup_queue
  pktgen: do not sleep with the thread lock held.
  net: mvpp2: Use strscpy to handle stat strings
  net: rds: fix memory leak in rds_ib_flush_mr_pool
  ...

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
116 files changed:
1  2 
MAINTAINERS
drivers/media/dvb-frontends/si2168.c
drivers/media/i2c/cx25840/cx25840-core.c
drivers/media/i2c/cx25840/cx25840-core.h
drivers/media/i2c/cx25840/cx25840-vbi.c
drivers/media/i2c/smiapp/smiapp-quirk.c
drivers/media/mc/mc-device.c
drivers/media/mc/mc-devnode.c
drivers/media/mc/mc-entity.c
drivers/media/pci/cx23885/cx23885-dvb.c
drivers/media/pci/saa7164/saa7164-core.c
drivers/media/platform/atmel/atmel-isc.c
drivers/media/platform/coda/coda-bit.c
drivers/media/platform/coda/coda-common.c
drivers/media/platform/coda/coda-h264.c
drivers/media/platform/coda/coda.h
drivers/media/platform/coda/coda_regs.h
drivers/media/platform/davinci/vpss.c
drivers/media/platform/exynos-gsc/gsc-core.c
drivers/media/platform/exynos-gsc/gsc-m2m.c
drivers/media/platform/exynos4-is/fimc-m2m.c
drivers/media/platform/exynos4-is/media-dev.c
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.h
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h
drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_if.c
drivers/media/platform/mtk-vcodec/vdec/vdec_vp8_if.c
drivers/media/platform/mtk-vcodec/vdec/vdec_vp9_if.c
drivers/media/platform/mtk-vcodec/vdec_drv_base.h
drivers/media/platform/mtk-vcodec/vdec_drv_if.c
drivers/media/platform/mtk-vcodec/vdec_drv_if.h
drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
drivers/media/platform/mtk-vcodec/venc_drv_base.h
drivers/media/platform/mtk-vcodec/venc_drv_if.c
drivers/media/platform/mtk-vcodec/venc_drv_if.h
drivers/media/platform/mtk-vcodec/venc_ipi_msg.h
drivers/media/platform/mtk-vcodec/venc_vpu_if.c
drivers/media/platform/mtk-vcodec/venc_vpu_if.h
drivers/media/platform/mtk-vpu/mtk_vpu.c
drivers/media/platform/pxa_camera.c
drivers/media/platform/qcom/venus/core.c
drivers/media/platform/qcom/venus/firmware.c
drivers/media/platform/qcom/venus/helpers.c
drivers/media/platform/qcom/venus/hfi_cmds.c
drivers/media/platform/qcom/venus/vdec.c
drivers/media/platform/qcom/venus/vdec_ctrls.c
drivers/media/platform/qcom/venus/venc.c
drivers/media/platform/qcom/venus/venc_ctrls.c
drivers/media/platform/s5p-mfc/s5p_mfc.c
drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
drivers/media/platform/vimc/vimc-core.c
drivers/media/platform/vimc/vimc-debayer.c
drivers/media/platform/vimc/vimc-scaler.c
drivers/media/platform/vimc/vimc-sensor.c
drivers/media/radio/dsbr100.c
drivers/media/radio/radio-isa.c
drivers/media/radio/radio-keene.c
drivers/media/radio/radio-ma901.c
drivers/media/radio/radio-mr800.c
drivers/media/radio/radio-si476x.c
drivers/media/radio/radio-tea5764.c
drivers/media/radio/radio-tea5777.c
drivers/media/radio/radio-timb.c
drivers/media/radio/radio-wl1273.c
drivers/media/radio/si470x/radio-si470x-i2c.c
drivers/media/radio/si470x/radio-si470x-usb.c
drivers/media/radio/si4713/radio-platform-si4713.c
drivers/media/radio/tea575x.c
drivers/media/radio/wl128x/fmdrv_v4l2.c
drivers/media/usb/airspy/airspy.c
drivers/media/usb/au0828/au0828-core.c
drivers/media/usb/au0828/au0828-video.c
drivers/media/usb/cpia2/cpia2_usb.c
drivers/media/usb/cpia2/cpia2_v4l.c
drivers/media/usb/dvb-usb-v2/dvbsky.c
drivers/media/usb/dvb-usb/cxusb.c
drivers/media/usb/dvb-usb/dvb-usb-init.c
drivers/media/usb/go7007/go7007-v4l2.c
drivers/media/usb/gspca/gspca.c
drivers/media/usb/hackrf/hackrf.c
drivers/media/usb/hdpvr/hdpvr-video.c
drivers/media/usb/msi2500/msi2500.c
drivers/media/usb/pwc/pwc-if.c
drivers/media/usb/pwc/pwc-v4l.c
drivers/media/usb/pwc/pwc.h
drivers/media/usb/s2255/s2255drv.c
drivers/media/usb/stk1160/stk1160-v4l.c
drivers/media/usb/usbvision/usbvision-video.c
drivers/media/usb/zr364xx/zr364xx.c
drivers/media/v4l2-core/v4l2-ctrls.c
drivers/media/v4l2-core/v4l2-dev.c
drivers/media/v4l2-core/v4l2-fwnode.c
drivers/media/v4l2-core/v4l2-ioctl.c
drivers/media/v4l2-core/v4l2-mem2mem.c
include/media/v4l2-common.h
include/media/v4l2-ctrls.h
include/media/v4l2-mem2mem.h

diff --cc MAINTAINERS
Simple merge
Simple merge
index f071a9434fed9cf317cdb1400eef5ac556b963b5,3ecf79d242f27465d3d1969125f342221335f57b..0de946fe2109d796f5a0126a5fdddd3730b43ef8
   *
   * CX23888 DIF support for the HVR1850
   * Copyright (C) 2011 Steven Toth <stoth@kernellabs.com>
-  *
-  * 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.
 + *
 + * CX2584x pin to pad mapping and output format configuration support are
 + * Copyright (C) 2011 Maciej S. Szmigiero <mail@maciej.szmigiero.name>
   */
  
 -
  #include <linux/kernel.h>
  #include <linux/module.h>
  #include <linux/slab.h>
index 8e2a66493e62726966aa7fcebcbc3f988c6992d8,0000000000000000000000000000000000000000..e19df5165e78c081c157ac5cbc47f868b9448689
mode 100644,000000..100644
--- /dev/null
@@@ -1,910 -1,0 +1,902 @@@
-  *
-  * This program is free software; you can redistribute it and/or modify
-  * it under the terms of the GNU General Public License version 2 as
-  * published by the Free Software Foundation.
-  *
-  * 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.
++// SPDX-License-Identifier: GPL-2.0-only
 +/*
 + * Media device
 + *
 + * Copyright (C) 2010 Nokia Corporation
 + *
 + * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
 + *         Sakari Ailus <sakari.ailus@iki.fi>
 + */
 +
 +#include <linux/compat.h>
 +#include <linux/export.h>
 +#include <linux/idr.h>
 +#include <linux/ioctl.h>
 +#include <linux/media.h>
 +#include <linux/slab.h>
 +#include <linux/types.h>
 +#include <linux/pci.h>
 +#include <linux/usb.h>
 +#include <linux/version.h>
 +
 +#include <media/media-device.h>
 +#include <media/media-devnode.h>
 +#include <media/media-entity.h>
 +#include <media/media-request.h>
 +
 +#ifdef CONFIG_MEDIA_CONTROLLER
 +
 +/*
 + * Legacy defines from linux/media.h. This is the only place we need this
 + * so we just define it here. The media.h header doesn't expose it to the
 + * kernel to prevent it from being used by drivers, but here (and only here!)
 + * we need it to handle the legacy behavior.
 + */
 +#define MEDIA_ENT_SUBTYPE_MASK                        0x0000ffff
 +#define MEDIA_ENT_T_DEVNODE_UNKNOWN           (MEDIA_ENT_F_OLD_BASE | \
 +                                               MEDIA_ENT_SUBTYPE_MASK)
 +
 +/* -----------------------------------------------------------------------------
 + * Userspace API
 + */
 +
 +static inline void __user *media_get_uptr(__u64 arg)
 +{
 +      return (void __user *)(uintptr_t)arg;
 +}
 +
 +static int media_device_open(struct file *filp)
 +{
 +      return 0;
 +}
 +
 +static int media_device_close(struct file *filp)
 +{
 +      return 0;
 +}
 +
 +static long media_device_get_info(struct media_device *dev, void *arg)
 +{
 +      struct media_device_info *info = arg;
 +
 +      memset(info, 0, sizeof(*info));
 +
 +      if (dev->driver_name[0])
 +              strscpy(info->driver, dev->driver_name, sizeof(info->driver));
 +      else
 +              strscpy(info->driver, dev->dev->driver->name,
 +                      sizeof(info->driver));
 +
 +      strscpy(info->model, dev->model, sizeof(info->model));
 +      strscpy(info->serial, dev->serial, sizeof(info->serial));
 +      strscpy(info->bus_info, dev->bus_info, sizeof(info->bus_info));
 +
 +      info->media_version = LINUX_VERSION_CODE;
 +      info->driver_version = info->media_version;
 +      info->hw_revision = dev->hw_revision;
 +
 +      return 0;
 +}
 +
 +static struct media_entity *find_entity(struct media_device *mdev, u32 id)
 +{
 +      struct media_entity *entity;
 +      int next = id & MEDIA_ENT_ID_FLAG_NEXT;
 +
 +      id &= ~MEDIA_ENT_ID_FLAG_NEXT;
 +
 +      media_device_for_each_entity(entity, mdev) {
 +              if (((media_entity_id(entity) == id) && !next) ||
 +                  ((media_entity_id(entity) > id) && next)) {
 +                      return entity;
 +              }
 +      }
 +
 +      return NULL;
 +}
 +
 +static long media_device_enum_entities(struct media_device *mdev, void *arg)
 +{
 +      struct media_entity_desc *entd = arg;
 +      struct media_entity *ent;
 +
 +      ent = find_entity(mdev, entd->id);
 +      if (ent == NULL)
 +              return -EINVAL;
 +
 +      memset(entd, 0, sizeof(*entd));
 +
 +      entd->id = media_entity_id(ent);
 +      if (ent->name)
 +              strscpy(entd->name, ent->name, sizeof(entd->name));
 +      entd->type = ent->function;
 +      entd->revision = 0;             /* Unused */
 +      entd->flags = ent->flags;
 +      entd->group_id = 0;             /* Unused */
 +      entd->pads = ent->num_pads;
 +      entd->links = ent->num_links - ent->num_backlinks;
 +
 +      /*
 +       * Workaround for a bug at media-ctl <= v1.10 that makes it to
 +       * do the wrong thing if the entity function doesn't belong to
 +       * either MEDIA_ENT_F_OLD_BASE or MEDIA_ENT_F_OLD_SUBDEV_BASE
 +       * Ranges.
 +       *
 +       * Non-subdevices are expected to be at the MEDIA_ENT_F_OLD_BASE,
 +       * or, otherwise, will be silently ignored by media-ctl when
 +       * printing the graphviz diagram. So, map them into the devnode
 +       * old range.
 +       */
 +      if (ent->function < MEDIA_ENT_F_OLD_BASE ||
 +          ent->function > MEDIA_ENT_F_TUNER) {
 +              if (is_media_entity_v4l2_subdev(ent))
 +                      entd->type = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
 +              else if (ent->function != MEDIA_ENT_F_IO_V4L)
 +                      entd->type = MEDIA_ENT_T_DEVNODE_UNKNOWN;
 +      }
 +
 +      memcpy(&entd->raw, &ent->info, sizeof(ent->info));
 +
 +      return 0;
 +}
 +
 +static void media_device_kpad_to_upad(const struct media_pad *kpad,
 +                                    struct media_pad_desc *upad)
 +{
 +      upad->entity = media_entity_id(kpad->entity);
 +      upad->index = kpad->index;
 +      upad->flags = kpad->flags;
 +}
 +
 +static long media_device_enum_links(struct media_device *mdev, void *arg)
 +{
 +      struct media_links_enum *links = arg;
 +      struct media_entity *entity;
 +
 +      entity = find_entity(mdev, links->entity);
 +      if (entity == NULL)
 +              return -EINVAL;
 +
 +      if (links->pads) {
 +              unsigned int p;
 +
 +              for (p = 0; p < entity->num_pads; p++) {
 +                      struct media_pad_desc pad;
 +
 +                      memset(&pad, 0, sizeof(pad));
 +                      media_device_kpad_to_upad(&entity->pads[p], &pad);
 +                      if (copy_to_user(&links->pads[p], &pad, sizeof(pad)))
 +                              return -EFAULT;
 +              }
 +      }
 +
 +      if (links->links) {
 +              struct media_link *link;
 +              struct media_link_desc __user *ulink_desc = links->links;
 +
 +              list_for_each_entry(link, &entity->links, list) {
 +                      struct media_link_desc klink_desc;
 +
 +                      /* Ignore backlinks. */
 +                      if (link->source->entity != entity)
 +                              continue;
 +                      memset(&klink_desc, 0, sizeof(klink_desc));
 +                      media_device_kpad_to_upad(link->source,
 +                                                &klink_desc.source);
 +                      media_device_kpad_to_upad(link->sink,
 +                                                &klink_desc.sink);
 +                      klink_desc.flags = link->flags;
 +                      if (copy_to_user(ulink_desc, &klink_desc,
 +                                       sizeof(*ulink_desc)))
 +                              return -EFAULT;
 +                      ulink_desc++;
 +              }
 +      }
 +      memset(links->reserved, 0, sizeof(links->reserved));
 +
 +      return 0;
 +}
 +
 +static long media_device_setup_link(struct media_device *mdev, void *arg)
 +{
 +      struct media_link_desc *linkd = arg;
 +      struct media_link *link = NULL;
 +      struct media_entity *source;
 +      struct media_entity *sink;
 +
 +      /* Find the source and sink entities and link.
 +       */
 +      source = find_entity(mdev, linkd->source.entity);
 +      sink = find_entity(mdev, linkd->sink.entity);
 +
 +      if (source == NULL || sink == NULL)
 +              return -EINVAL;
 +
 +      if (linkd->source.index >= source->num_pads ||
 +          linkd->sink.index >= sink->num_pads)
 +              return -EINVAL;
 +
 +      link = media_entity_find_link(&source->pads[linkd->source.index],
 +                                    &sink->pads[linkd->sink.index]);
 +      if (link == NULL)
 +              return -EINVAL;
 +
 +      memset(linkd->reserved, 0, sizeof(linkd->reserved));
 +
 +      /* Setup the link on both entities. */
 +      return __media_entity_setup_link(link, linkd->flags);
 +}
 +
 +static long media_device_get_topology(struct media_device *mdev, void *arg)
 +{
 +      struct media_v2_topology *topo = arg;
 +      struct media_entity *entity;
 +      struct media_interface *intf;
 +      struct media_pad *pad;
 +      struct media_link *link;
 +      struct media_v2_entity kentity, __user *uentity;
 +      struct media_v2_interface kintf, __user *uintf;
 +      struct media_v2_pad kpad, __user *upad;
 +      struct media_v2_link klink, __user *ulink;
 +      unsigned int i;
 +      int ret = 0;
 +
 +      topo->topology_version = mdev->topology_version;
 +
 +      /* Get entities and number of entities */
 +      i = 0;
 +      uentity = media_get_uptr(topo->ptr_entities);
 +      media_device_for_each_entity(entity, mdev) {
 +              i++;
 +              if (ret || !uentity)
 +                      continue;
 +
 +              if (i > topo->num_entities) {
 +                      ret = -ENOSPC;
 +                      continue;
 +              }
 +
 +              /* Copy fields to userspace struct if not error */
 +              memset(&kentity, 0, sizeof(kentity));
 +              kentity.id = entity->graph_obj.id;
 +              kentity.function = entity->function;
 +              kentity.flags = entity->flags;
 +              strscpy(kentity.name, entity->name,
 +                      sizeof(kentity.name));
 +
 +              if (copy_to_user(uentity, &kentity, sizeof(kentity)))
 +                      ret = -EFAULT;
 +              uentity++;
 +      }
 +      topo->num_entities = i;
 +      topo->reserved1 = 0;
 +
 +      /* Get interfaces and number of interfaces */
 +      i = 0;
 +      uintf = media_get_uptr(topo->ptr_interfaces);
 +      media_device_for_each_intf(intf, mdev) {
 +              i++;
 +              if (ret || !uintf)
 +                      continue;
 +
 +              if (i > topo->num_interfaces) {
 +                      ret = -ENOSPC;
 +                      continue;
 +              }
 +
 +              memset(&kintf, 0, sizeof(kintf));
 +
 +              /* Copy intf fields to userspace struct */
 +              kintf.id = intf->graph_obj.id;
 +              kintf.intf_type = intf->type;
 +              kintf.flags = intf->flags;
 +
 +              if (media_type(&intf->graph_obj) == MEDIA_GRAPH_INTF_DEVNODE) {
 +                      struct media_intf_devnode *devnode;
 +
 +                      devnode = intf_to_devnode(intf);
 +
 +                      kintf.devnode.major = devnode->major;
 +                      kintf.devnode.minor = devnode->minor;
 +              }
 +
 +              if (copy_to_user(uintf, &kintf, sizeof(kintf)))
 +                      ret = -EFAULT;
 +              uintf++;
 +      }
 +      topo->num_interfaces = i;
 +      topo->reserved2 = 0;
 +
 +      /* Get pads and number of pads */
 +      i = 0;
 +      upad = media_get_uptr(topo->ptr_pads);
 +      media_device_for_each_pad(pad, mdev) {
 +              i++;
 +              if (ret || !upad)
 +                      continue;
 +
 +              if (i > topo->num_pads) {
 +                      ret = -ENOSPC;
 +                      continue;
 +              }
 +
 +              memset(&kpad, 0, sizeof(kpad));
 +
 +              /* Copy pad fields to userspace struct */
 +              kpad.id = pad->graph_obj.id;
 +              kpad.entity_id = pad->entity->graph_obj.id;
 +              kpad.flags = pad->flags;
 +              kpad.index = pad->index;
 +
 +              if (copy_to_user(upad, &kpad, sizeof(kpad)))
 +                      ret = -EFAULT;
 +              upad++;
 +      }
 +      topo->num_pads = i;
 +      topo->reserved3 = 0;
 +
 +      /* Get links and number of links */
 +      i = 0;
 +      ulink = media_get_uptr(topo->ptr_links);
 +      media_device_for_each_link(link, mdev) {
 +              if (link->is_backlink)
 +                      continue;
 +
 +              i++;
 +
 +              if (ret || !ulink)
 +                      continue;
 +
 +              if (i > topo->num_links) {
 +                      ret = -ENOSPC;
 +                      continue;
 +              }
 +
 +              memset(&klink, 0, sizeof(klink));
 +
 +              /* Copy link fields to userspace struct */
 +              klink.id = link->graph_obj.id;
 +              klink.source_id = link->gobj0->id;
 +              klink.sink_id = link->gobj1->id;
 +              klink.flags = link->flags;
 +
 +              if (copy_to_user(ulink, &klink, sizeof(klink)))
 +                      ret = -EFAULT;
 +              ulink++;
 +      }
 +      topo->num_links = i;
 +      topo->reserved4 = 0;
 +
 +      return ret;
 +}
 +
 +static long media_device_request_alloc(struct media_device *mdev,
 +                                     int *alloc_fd)
 +{
 +#ifdef CONFIG_MEDIA_CONTROLLER_REQUEST_API
 +      if (!mdev->ops || !mdev->ops->req_validate || !mdev->ops->req_queue)
 +              return -ENOTTY;
 +
 +      return media_request_alloc(mdev, alloc_fd);
 +#else
 +      return -ENOTTY;
 +#endif
 +}
 +
 +static long copy_arg_from_user(void *karg, void __user *uarg, unsigned int cmd)
 +{
 +      if ((_IOC_DIR(cmd) & _IOC_WRITE) &&
 +          copy_from_user(karg, uarg, _IOC_SIZE(cmd)))
 +              return -EFAULT;
 +
 +      return 0;
 +}
 +
 +static long copy_arg_to_user(void __user *uarg, void *karg, unsigned int cmd)
 +{
 +      if ((_IOC_DIR(cmd) & _IOC_READ) &&
 +          copy_to_user(uarg, karg, _IOC_SIZE(cmd)))
 +              return -EFAULT;
 +
 +      return 0;
 +}
 +
 +/* Do acquire the graph mutex */
 +#define MEDIA_IOC_FL_GRAPH_MUTEX      BIT(0)
 +
 +#define MEDIA_IOC_ARG(__cmd, func, fl, from_user, to_user)            \
 +      [_IOC_NR(MEDIA_IOC_##__cmd)] = {                                \
 +              .cmd = MEDIA_IOC_##__cmd,                               \
 +              .fn = (long (*)(struct media_device *, void *))func,    \
 +              .flags = fl,                                            \
 +              .arg_from_user = from_user,                             \
 +              .arg_to_user = to_user,                                 \
 +      }
 +
 +#define MEDIA_IOC(__cmd, func, fl)                                    \
 +      MEDIA_IOC_ARG(__cmd, func, fl, copy_arg_from_user, copy_arg_to_user)
 +
 +/* the table is indexed by _IOC_NR(cmd) */
 +struct media_ioctl_info {
 +      unsigned int cmd;
 +      unsigned short flags;
 +      long (*fn)(struct media_device *dev, void *arg);
 +      long (*arg_from_user)(void *karg, void __user *uarg, unsigned int cmd);
 +      long (*arg_to_user)(void __user *uarg, void *karg, unsigned int cmd);
 +};
 +
 +static const struct media_ioctl_info ioctl_info[] = {
 +      MEDIA_IOC(DEVICE_INFO, media_device_get_info, MEDIA_IOC_FL_GRAPH_MUTEX),
 +      MEDIA_IOC(ENUM_ENTITIES, media_device_enum_entities, MEDIA_IOC_FL_GRAPH_MUTEX),
 +      MEDIA_IOC(ENUM_LINKS, media_device_enum_links, MEDIA_IOC_FL_GRAPH_MUTEX),
 +      MEDIA_IOC(SETUP_LINK, media_device_setup_link, MEDIA_IOC_FL_GRAPH_MUTEX),
 +      MEDIA_IOC(G_TOPOLOGY, media_device_get_topology, MEDIA_IOC_FL_GRAPH_MUTEX),
 +      MEDIA_IOC(REQUEST_ALLOC, media_device_request_alloc, 0),
 +};
 +
 +static long media_device_ioctl(struct file *filp, unsigned int cmd,
 +                             unsigned long __arg)
 +{
 +      struct media_devnode *devnode = media_devnode_data(filp);
 +      struct media_device *dev = devnode->media_dev;
 +      const struct media_ioctl_info *info;
 +      void __user *arg = (void __user *)__arg;
 +      char __karg[256], *karg = __karg;
 +      long ret;
 +
 +      if (_IOC_NR(cmd) >= ARRAY_SIZE(ioctl_info)
 +          || ioctl_info[_IOC_NR(cmd)].cmd != cmd)
 +              return -ENOIOCTLCMD;
 +
 +      info = &ioctl_info[_IOC_NR(cmd)];
 +
 +      if (_IOC_SIZE(info->cmd) > sizeof(__karg)) {
 +              karg = kmalloc(_IOC_SIZE(info->cmd), GFP_KERNEL);
 +              if (!karg)
 +                      return -ENOMEM;
 +      }
 +
 +      if (info->arg_from_user) {
 +              ret = info->arg_from_user(karg, arg, cmd);
 +              if (ret)
 +                      goto out_free;
 +      }
 +
 +      if (info->flags & MEDIA_IOC_FL_GRAPH_MUTEX)
 +              mutex_lock(&dev->graph_mutex);
 +
 +      ret = info->fn(dev, karg);
 +
 +      if (info->flags & MEDIA_IOC_FL_GRAPH_MUTEX)
 +              mutex_unlock(&dev->graph_mutex);
 +
 +      if (!ret && info->arg_to_user)
 +              ret = info->arg_to_user(arg, karg, cmd);
 +
 +out_free:
 +      if (karg != __karg)
 +              kfree(karg);
 +
 +      return ret;
 +}
 +
 +#ifdef CONFIG_COMPAT
 +
 +struct media_links_enum32 {
 +      __u32 entity;
 +      compat_uptr_t pads; /* struct media_pad_desc * */
 +      compat_uptr_t links; /* struct media_link_desc * */
 +      __u32 reserved[4];
 +};
 +
 +static long media_device_enum_links32(struct media_device *mdev,
 +                                    struct media_links_enum32 __user *ulinks)
 +{
 +      struct media_links_enum links;
 +      compat_uptr_t pads_ptr, links_ptr;
 +      int ret;
 +
 +      memset(&links, 0, sizeof(links));
 +
 +      if (get_user(links.entity, &ulinks->entity)
 +          || get_user(pads_ptr, &ulinks->pads)
 +          || get_user(links_ptr, &ulinks->links))
 +              return -EFAULT;
 +
 +      links.pads = compat_ptr(pads_ptr);
 +      links.links = compat_ptr(links_ptr);
 +
 +      ret = media_device_enum_links(mdev, &links);
 +      if (ret)
 +              return ret;
 +
 +      if (copy_to_user(ulinks->reserved, links.reserved,
 +                       sizeof(ulinks->reserved)))
 +              return -EFAULT;
 +      return 0;
 +}
 +
 +#define MEDIA_IOC_ENUM_LINKS32                _IOWR('|', 0x02, struct media_links_enum32)
 +
 +static long media_device_compat_ioctl(struct file *filp, unsigned int cmd,
 +                                    unsigned long arg)
 +{
 +      struct media_devnode *devnode = media_devnode_data(filp);
 +      struct media_device *dev = devnode->media_dev;
 +      long ret;
 +
 +      switch (cmd) {
 +      case MEDIA_IOC_ENUM_LINKS32:
 +              mutex_lock(&dev->graph_mutex);
 +              ret = media_device_enum_links32(dev,
 +                              (struct media_links_enum32 __user *)arg);
 +              mutex_unlock(&dev->graph_mutex);
 +              break;
 +
 +      default:
 +              return media_device_ioctl(filp, cmd, arg);
 +      }
 +
 +      return ret;
 +}
 +#endif /* CONFIG_COMPAT */
 +
 +static const struct media_file_operations media_device_fops = {
 +      .owner = THIS_MODULE,
 +      .open = media_device_open,
 +      .ioctl = media_device_ioctl,
 +#ifdef CONFIG_COMPAT
 +      .compat_ioctl = media_device_compat_ioctl,
 +#endif /* CONFIG_COMPAT */
 +      .release = media_device_close,
 +};
 +
 +/* -----------------------------------------------------------------------------
 + * sysfs
 + */
 +
 +static ssize_t show_model(struct device *cd,
 +                        struct device_attribute *attr, char *buf)
 +{
 +      struct media_devnode *devnode = to_media_devnode(cd);
 +      struct media_device *mdev = devnode->media_dev;
 +
 +      return sprintf(buf, "%.*s\n", (int)sizeof(mdev->model), mdev->model);
 +}
 +
 +static DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
 +
 +/* -----------------------------------------------------------------------------
 + * Registration/unregistration
 + */
 +
 +static void media_device_release(struct media_devnode *devnode)
 +{
 +      dev_dbg(devnode->parent, "Media device released\n");
 +}
 +
 +/**
 + * media_device_register_entity - Register an entity with a media device
 + * @mdev:     The media device
 + * @entity:   The entity
 + */
 +int __must_check media_device_register_entity(struct media_device *mdev,
 +                                            struct media_entity *entity)
 +{
 +      struct media_entity_notify *notify, *next;
 +      unsigned int i;
 +      int ret;
 +
 +      if (entity->function == MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN ||
 +          entity->function == MEDIA_ENT_F_UNKNOWN)
 +              dev_warn(mdev->dev,
 +                       "Entity type for entity %s was not initialized!\n",
 +                       entity->name);
 +
 +      /* Warn if we apparently re-register an entity */
 +      WARN_ON(entity->graph_obj.mdev != NULL);
 +      entity->graph_obj.mdev = mdev;
 +      INIT_LIST_HEAD(&entity->links);
 +      entity->num_links = 0;
 +      entity->num_backlinks = 0;
 +
 +      ret = ida_alloc_min(&mdev->entity_internal_idx, 1, GFP_KERNEL);
 +      if (ret < 0)
 +              return ret;
 +      entity->internal_idx = ret;
 +
 +      mutex_lock(&mdev->graph_mutex);
 +      mdev->entity_internal_idx_max =
 +              max(mdev->entity_internal_idx_max, entity->internal_idx);
 +
 +      /* Initialize media_gobj embedded at the entity */
 +      media_gobj_create(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj);
 +
 +      /* Initialize objects at the pads */
 +      for (i = 0; i < entity->num_pads; i++)
 +              media_gobj_create(mdev, MEDIA_GRAPH_PAD,
 +                             &entity->pads[i].graph_obj);
 +
 +      /* invoke entity_notify callbacks */
 +      list_for_each_entry_safe(notify, next, &mdev->entity_notify, list)
 +              notify->notify(entity, notify->notify_data);
 +
 +      if (mdev->entity_internal_idx_max
 +          >= mdev->pm_count_walk.ent_enum.idx_max) {
 +              struct media_graph new = { .top = 0 };
 +
 +              /*
 +               * Initialise the new graph walk before cleaning up
 +               * the old one in order not to spoil the graph walk
 +               * object of the media device if graph walk init fails.
 +               */
 +              ret = media_graph_walk_init(&new, mdev);
 +              if (ret) {
 +                      mutex_unlock(&mdev->graph_mutex);
 +                      return ret;
 +              }
 +              media_graph_walk_cleanup(&mdev->pm_count_walk);
 +              mdev->pm_count_walk = new;
 +      }
 +      mutex_unlock(&mdev->graph_mutex);
 +
 +      return 0;
 +}
 +EXPORT_SYMBOL_GPL(media_device_register_entity);
 +
 +static void __media_device_unregister_entity(struct media_entity *entity)
 +{
 +      struct media_device *mdev = entity->graph_obj.mdev;
 +      struct media_link *link, *tmp;
 +      struct media_interface *intf;
 +      unsigned int i;
 +
 +      ida_free(&mdev->entity_internal_idx, entity->internal_idx);
 +
 +      /* Remove all interface links pointing to this entity */
 +      list_for_each_entry(intf, &mdev->interfaces, graph_obj.list) {
 +              list_for_each_entry_safe(link, tmp, &intf->links, list) {
 +                      if (link->entity == entity)
 +                              __media_remove_intf_link(link);
 +              }
 +      }
 +
 +      /* Remove all data links that belong to this entity */
 +      __media_entity_remove_links(entity);
 +
 +      /* Remove all pads that belong to this entity */
 +      for (i = 0; i < entity->num_pads; i++)
 +              media_gobj_destroy(&entity->pads[i].graph_obj);
 +
 +      /* Remove the entity */
 +      media_gobj_destroy(&entity->graph_obj);
 +
 +      /* invoke entity_notify callbacks to handle entity removal?? */
 +
 +      entity->graph_obj.mdev = NULL;
 +}
 +
 +void media_device_unregister_entity(struct media_entity *entity)
 +{
 +      struct media_device *mdev = entity->graph_obj.mdev;
 +
 +      if (mdev == NULL)
 +              return;
 +
 +      mutex_lock(&mdev->graph_mutex);
 +      __media_device_unregister_entity(entity);
 +      mutex_unlock(&mdev->graph_mutex);
 +}
 +EXPORT_SYMBOL_GPL(media_device_unregister_entity);
 +
 +/**
 + * media_device_init() - initialize a media device
 + * @mdev:     The media device
 + *
 + * The caller is responsible for initializing the media device before
 + * registration. The following fields must be set:
 + *
 + * - dev must point to the parent device
 + * - model must be filled with the device model name
 + */
 +void media_device_init(struct media_device *mdev)
 +{
 +      INIT_LIST_HEAD(&mdev->entities);
 +      INIT_LIST_HEAD(&mdev->interfaces);
 +      INIT_LIST_HEAD(&mdev->pads);
 +      INIT_LIST_HEAD(&mdev->links);
 +      INIT_LIST_HEAD(&mdev->entity_notify);
 +
 +      mutex_init(&mdev->req_queue_mutex);
 +      mutex_init(&mdev->graph_mutex);
 +      ida_init(&mdev->entity_internal_idx);
 +
 +      atomic_set(&mdev->request_id, 0);
 +
 +      dev_dbg(mdev->dev, "Media device initialized\n");
 +}
 +EXPORT_SYMBOL_GPL(media_device_init);
 +
 +void media_device_cleanup(struct media_device *mdev)
 +{
 +      ida_destroy(&mdev->entity_internal_idx);
 +      mdev->entity_internal_idx_max = 0;
 +      media_graph_walk_cleanup(&mdev->pm_count_walk);
 +      mutex_destroy(&mdev->graph_mutex);
 +      mutex_destroy(&mdev->req_queue_mutex);
 +}
 +EXPORT_SYMBOL_GPL(media_device_cleanup);
 +
 +int __must_check __media_device_register(struct media_device *mdev,
 +                                       struct module *owner)
 +{
 +      struct media_devnode *devnode;
 +      int ret;
 +
 +      devnode = kzalloc(sizeof(*devnode), GFP_KERNEL);
 +      if (!devnode)
 +              return -ENOMEM;
 +
 +      /* Register the device node. */
 +      mdev->devnode = devnode;
 +      devnode->fops = &media_device_fops;
 +      devnode->parent = mdev->dev;
 +      devnode->release = media_device_release;
 +
 +      /* Set version 0 to indicate user-space that the graph is static */
 +      mdev->topology_version = 0;
 +
 +      ret = media_devnode_register(mdev, devnode, owner);
 +      if (ret < 0) {
 +              /* devnode free is handled in media_devnode_*() */
 +              mdev->devnode = NULL;
 +              return ret;
 +      }
 +
 +      ret = device_create_file(&devnode->dev, &dev_attr_model);
 +      if (ret < 0) {
 +              /* devnode free is handled in media_devnode_*() */
 +              mdev->devnode = NULL;
 +              media_devnode_unregister_prepare(devnode);
 +              media_devnode_unregister(devnode);
 +              return ret;
 +      }
 +
 +      dev_dbg(mdev->dev, "Media device registered\n");
 +
 +      return 0;
 +}
 +EXPORT_SYMBOL_GPL(__media_device_register);
 +
 +int __must_check media_device_register_entity_notify(struct media_device *mdev,
 +                                      struct media_entity_notify *nptr)
 +{
 +      mutex_lock(&mdev->graph_mutex);
 +      list_add_tail(&nptr->list, &mdev->entity_notify);
 +      mutex_unlock(&mdev->graph_mutex);
 +      return 0;
 +}
 +EXPORT_SYMBOL_GPL(media_device_register_entity_notify);
 +
 +/*
 + * Note: Should be called with mdev->lock held.
 + */
 +static void __media_device_unregister_entity_notify(struct media_device *mdev,
 +                                      struct media_entity_notify *nptr)
 +{
 +      list_del(&nptr->list);
 +}
 +
 +void media_device_unregister_entity_notify(struct media_device *mdev,
 +                                      struct media_entity_notify *nptr)
 +{
 +      mutex_lock(&mdev->graph_mutex);
 +      __media_device_unregister_entity_notify(mdev, nptr);
 +      mutex_unlock(&mdev->graph_mutex);
 +}
 +EXPORT_SYMBOL_GPL(media_device_unregister_entity_notify);
 +
 +void media_device_unregister(struct media_device *mdev)
 +{
 +      struct media_entity *entity;
 +      struct media_entity *next;
 +      struct media_interface *intf, *tmp_intf;
 +      struct media_entity_notify *notify, *nextp;
 +
 +      if (mdev == NULL)
 +              return;
 +
 +      mutex_lock(&mdev->graph_mutex);
 +
 +      /* Check if mdev was ever registered at all */
 +      if (!media_devnode_is_registered(mdev->devnode)) {
 +              mutex_unlock(&mdev->graph_mutex);
 +              return;
 +      }
 +
 +      /* Clear the devnode register bit to avoid races with media dev open */
 +      media_devnode_unregister_prepare(mdev->devnode);
 +
 +      /* Remove all entities from the media device */
 +      list_for_each_entry_safe(entity, next, &mdev->entities, graph_obj.list)
 +              __media_device_unregister_entity(entity);
 +
 +      /* Remove all entity_notify callbacks from the media device */
 +      list_for_each_entry_safe(notify, nextp, &mdev->entity_notify, list)
 +              __media_device_unregister_entity_notify(mdev, notify);
 +
 +      /* Remove all interfaces from the media device */
 +      list_for_each_entry_safe(intf, tmp_intf, &mdev->interfaces,
 +                               graph_obj.list) {
 +              /*
 +               * Unlink the interface, but don't free it here; the
 +               * module which created it is responsible for freeing
 +               * it
 +               */
 +              __media_remove_intf_links(intf);
 +              media_gobj_destroy(&intf->graph_obj);
 +      }
 +
 +      mutex_unlock(&mdev->graph_mutex);
 +
 +      dev_dbg(mdev->dev, "Media device unregistered\n");
 +
 +      device_remove_file(&mdev->devnode->dev, &dev_attr_model);
 +      media_devnode_unregister(mdev->devnode);
 +      /* devnode free is handled in media_devnode_*() */
 +      mdev->devnode = NULL;
 +}
 +EXPORT_SYMBOL_GPL(media_device_unregister);
 +
 +#if IS_ENABLED(CONFIG_PCI)
 +void media_device_pci_init(struct media_device *mdev,
 +                         struct pci_dev *pci_dev,
 +                         const char *name)
 +{
 +      mdev->dev = &pci_dev->dev;
 +
 +      if (name)
 +              strscpy(mdev->model, name, sizeof(mdev->model));
 +      else
 +              strscpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model));
 +
 +      sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev));
 +
 +      mdev->hw_revision = (pci_dev->subsystem_vendor << 16)
 +                          | pci_dev->subsystem_device;
 +
 +      media_device_init(mdev);
 +}
 +EXPORT_SYMBOL_GPL(media_device_pci_init);
 +#endif
 +
 +#if IS_ENABLED(CONFIG_USB)
 +void __media_device_usb_init(struct media_device *mdev,
 +                           struct usb_device *udev,
 +                           const char *board_name,
 +                           const char *driver_name)
 +{
 +      mdev->dev = &udev->dev;
 +
 +      if (driver_name)
 +              strscpy(mdev->driver_name, driver_name,
 +                      sizeof(mdev->driver_name));
 +
 +      if (board_name)
 +              strscpy(mdev->model, board_name, sizeof(mdev->model));
 +      else if (udev->product)
 +              strscpy(mdev->model, udev->product, sizeof(mdev->model));
 +      else
 +              strscpy(mdev->model, "unknown model", sizeof(mdev->model));
 +      if (udev->serial)
 +              strscpy(mdev->serial, udev->serial, sizeof(mdev->serial));
 +      usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info));
 +      mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
 +
 +      media_device_init(mdev);
 +}
 +EXPORT_SYMBOL_GPL(__media_device_usb_init);
 +#endif
 +
 +
 +#endif /* CONFIG_MEDIA_CONTROLLER */
index d5aa30eeff4ac56252136f967b1cd7f955c9a65e,0000000000000000000000000000000000000000..f11382afe23bf280736244026890924d4f4729ba
mode 100644,000000..100644
--- /dev/null
@@@ -1,336 -1,0 +1,328 @@@
-  * This program is free software; you can redistribute it and/or modify
-  * it under the terms of the GNU General Public License version 2 as
-  * published by the Free Software Foundation.
-  *
-  * 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.
-  *
++// SPDX-License-Identifier: GPL-2.0-only
 +/*
 + * Media device node
 + *
 + * Copyright (C) 2010 Nokia Corporation
 + *
 + * Based on drivers/media/video/v4l2_dev.c code authored by
 + *    Mauro Carvalho Chehab <mchehab@kernel.org> (version 2)
 + *    Alan Cox, <alan@lxorguk.ukuu.org.uk> (version 1)
 + *
 + * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
 + *         Sakari Ailus <sakari.ailus@iki.fi>
 + *
 + * --
 + *
 + * Generic media device node infrastructure to register and unregister
 + * character devices using a dynamic major number and proper reference
 + * counting.
 + */
 +
 +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 +
 +#include <linux/errno.h>
 +#include <linux/init.h>
 +#include <linux/module.h>
 +#include <linux/kernel.h>
 +#include <linux/kmod.h>
 +#include <linux/slab.h>
 +#include <linux/mm.h>
 +#include <linux/string.h>
 +#include <linux/types.h>
 +#include <linux/uaccess.h>
 +
 +#include <media/media-devnode.h>
 +#include <media/media-device.h>
 +
 +#define MEDIA_NUM_DEVICES     256
 +#define MEDIA_NAME            "media"
 +
 +static dev_t media_dev_t;
 +
 +/*
 + *    Active devices
 + */
 +static DEFINE_MUTEX(media_devnode_lock);
 +static DECLARE_BITMAP(media_devnode_nums, MEDIA_NUM_DEVICES);
 +
 +/* Called when the last user of the media device exits. */
 +static void media_devnode_release(struct device *cd)
 +{
 +      struct media_devnode *devnode = to_media_devnode(cd);
 +
 +      mutex_lock(&media_devnode_lock);
 +      /* Mark device node number as free */
 +      clear_bit(devnode->minor, media_devnode_nums);
 +      mutex_unlock(&media_devnode_lock);
 +
 +      /* Release media_devnode and perform other cleanups as needed. */
 +      if (devnode->release)
 +              devnode->release(devnode);
 +
 +      kfree(devnode);
 +      pr_debug("%s: Media Devnode Deallocated\n", __func__);
 +}
 +
 +static struct bus_type media_bus_type = {
 +      .name = MEDIA_NAME,
 +};
 +
 +static ssize_t media_read(struct file *filp, char __user *buf,
 +              size_t sz, loff_t *off)
 +{
 +      struct media_devnode *devnode = media_devnode_data(filp);
 +
 +      if (!devnode->fops->read)
 +              return -EINVAL;
 +      if (!media_devnode_is_registered(devnode))
 +              return -EIO;
 +      return devnode->fops->read(filp, buf, sz, off);
 +}
 +
 +static ssize_t media_write(struct file *filp, const char __user *buf,
 +              size_t sz, loff_t *off)
 +{
 +      struct media_devnode *devnode = media_devnode_data(filp);
 +
 +      if (!devnode->fops->write)
 +              return -EINVAL;
 +      if (!media_devnode_is_registered(devnode))
 +              return -EIO;
 +      return devnode->fops->write(filp, buf, sz, off);
 +}
 +
 +static __poll_t media_poll(struct file *filp,
 +                             struct poll_table_struct *poll)
 +{
 +      struct media_devnode *devnode = media_devnode_data(filp);
 +
 +      if (!media_devnode_is_registered(devnode))
 +              return EPOLLERR | EPOLLHUP;
 +      if (!devnode->fops->poll)
 +              return DEFAULT_POLLMASK;
 +      return devnode->fops->poll(filp, poll);
 +}
 +
 +static long
 +__media_ioctl(struct file *filp, unsigned int cmd, unsigned long arg,
 +            long (*ioctl_func)(struct file *filp, unsigned int cmd,
 +                               unsigned long arg))
 +{
 +      struct media_devnode *devnode = media_devnode_data(filp);
 +
 +      if (!ioctl_func)
 +              return -ENOTTY;
 +
 +      if (!media_devnode_is_registered(devnode))
 +              return -EIO;
 +
 +      return ioctl_func(filp, cmd, arg);
 +}
 +
 +static long media_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 +{
 +      struct media_devnode *devnode = media_devnode_data(filp);
 +
 +      return __media_ioctl(filp, cmd, arg, devnode->fops->ioctl);
 +}
 +
 +#ifdef CONFIG_COMPAT
 +
 +static long media_compat_ioctl(struct file *filp, unsigned int cmd,
 +                             unsigned long arg)
 +{
 +      struct media_devnode *devnode = media_devnode_data(filp);
 +
 +      return __media_ioctl(filp, cmd, arg, devnode->fops->compat_ioctl);
 +}
 +
 +#endif /* CONFIG_COMPAT */
 +
 +/* Override for the open function */
 +static int media_open(struct inode *inode, struct file *filp)
 +{
 +      struct media_devnode *devnode;
 +      int ret;
 +
 +      /* Check if the media device is available. This needs to be done with
 +       * the media_devnode_lock held to prevent an open/unregister race:
 +       * without the lock, the device could be unregistered and freed between
 +       * the media_devnode_is_registered() and get_device() calls, leading to
 +       * a crash.
 +       */
 +      mutex_lock(&media_devnode_lock);
 +      devnode = container_of(inode->i_cdev, struct media_devnode, cdev);
 +      /* return ENXIO if the media device has been removed
 +         already or if it is not registered anymore. */
 +      if (!media_devnode_is_registered(devnode)) {
 +              mutex_unlock(&media_devnode_lock);
 +              return -ENXIO;
 +      }
 +      /* and increase the device refcount */
 +      get_device(&devnode->dev);
 +      mutex_unlock(&media_devnode_lock);
 +
 +      filp->private_data = devnode;
 +
 +      if (devnode->fops->open) {
 +              ret = devnode->fops->open(filp);
 +              if (ret) {
 +                      put_device(&devnode->dev);
 +                      filp->private_data = NULL;
 +                      return ret;
 +              }
 +      }
 +
 +      return 0;
 +}
 +
 +/* Override for the release function */
 +static int media_release(struct inode *inode, struct file *filp)
 +{
 +      struct media_devnode *devnode = media_devnode_data(filp);
 +
 +      if (devnode->fops->release)
 +              devnode->fops->release(filp);
 +
 +      filp->private_data = NULL;
 +
 +      /* decrease the refcount unconditionally since the release()
 +         return value is ignored. */
 +      put_device(&devnode->dev);
 +
 +      pr_debug("%s: Media Release\n", __func__);
 +      return 0;
 +}
 +
 +static const struct file_operations media_devnode_fops = {
 +      .owner = THIS_MODULE,
 +      .read = media_read,
 +      .write = media_write,
 +      .open = media_open,
 +      .unlocked_ioctl = media_ioctl,
 +#ifdef CONFIG_COMPAT
 +      .compat_ioctl = media_compat_ioctl,
 +#endif /* CONFIG_COMPAT */
 +      .release = media_release,
 +      .poll = media_poll,
 +      .llseek = no_llseek,
 +};
 +
 +int __must_check media_devnode_register(struct media_device *mdev,
 +                                      struct media_devnode *devnode,
 +                                      struct module *owner)
 +{
 +      int minor;
 +      int ret;
 +
 +      /* Part 1: Find a free minor number */
 +      mutex_lock(&media_devnode_lock);
 +      minor = find_next_zero_bit(media_devnode_nums, MEDIA_NUM_DEVICES, 0);
 +      if (minor == MEDIA_NUM_DEVICES) {
 +              mutex_unlock(&media_devnode_lock);
 +              pr_err("could not get a free minor\n");
 +              kfree(devnode);
 +              return -ENFILE;
 +      }
 +
 +      set_bit(minor, media_devnode_nums);
 +      mutex_unlock(&media_devnode_lock);
 +
 +      devnode->minor = minor;
 +      devnode->media_dev = mdev;
 +
 +      /* Part 1: Initialize dev now to use dev.kobj for cdev.kobj.parent */
 +      devnode->dev.bus = &media_bus_type;
 +      devnode->dev.devt = MKDEV(MAJOR(media_dev_t), devnode->minor);
 +      devnode->dev.release = media_devnode_release;
 +      if (devnode->parent)
 +              devnode->dev.parent = devnode->parent;
 +      dev_set_name(&devnode->dev, "media%d", devnode->minor);
 +      device_initialize(&devnode->dev);
 +
 +      /* Part 2: Initialize the character device */
 +      cdev_init(&devnode->cdev, &media_devnode_fops);
 +      devnode->cdev.owner = owner;
 +      kobject_set_name(&devnode->cdev.kobj, "media%d", devnode->minor);
 +
 +      /* Part 3: Add the media and char device */
 +      ret = cdev_device_add(&devnode->cdev, &devnode->dev);
 +      if (ret < 0) {
 +              pr_err("%s: cdev_device_add failed\n", __func__);
 +              goto cdev_add_error;
 +      }
 +
 +      /* Part 4: Activate this minor. The char device can now be used. */
 +      set_bit(MEDIA_FLAG_REGISTERED, &devnode->flags);
 +
 +      return 0;
 +
 +cdev_add_error:
 +      mutex_lock(&media_devnode_lock);
 +      clear_bit(devnode->minor, media_devnode_nums);
 +      devnode->media_dev = NULL;
 +      mutex_unlock(&media_devnode_lock);
 +
 +      put_device(&devnode->dev);
 +      return ret;
 +}
 +
 +void media_devnode_unregister_prepare(struct media_devnode *devnode)
 +{
 +      /* Check if devnode was ever registered at all */
 +      if (!media_devnode_is_registered(devnode))
 +              return;
 +
 +      mutex_lock(&media_devnode_lock);
 +      clear_bit(MEDIA_FLAG_REGISTERED, &devnode->flags);
 +      mutex_unlock(&media_devnode_lock);
 +}
 +
 +void media_devnode_unregister(struct media_devnode *devnode)
 +{
 +      mutex_lock(&media_devnode_lock);
 +      /* Delete the cdev on this minor as well */
 +      cdev_device_del(&devnode->cdev, &devnode->dev);
 +      devnode->media_dev = NULL;
 +      mutex_unlock(&media_devnode_lock);
 +
 +      put_device(&devnode->dev);
 +}
 +
 +/*
 + *    Initialise media for linux
 + */
 +static int __init media_devnode_init(void)
 +{
 +      int ret;
 +
 +      pr_info("Linux media interface: v0.10\n");
 +      ret = alloc_chrdev_region(&media_dev_t, 0, MEDIA_NUM_DEVICES,
 +                                MEDIA_NAME);
 +      if (ret < 0) {
 +              pr_warn("unable to allocate major\n");
 +              return ret;
 +      }
 +
 +      ret = bus_register(&media_bus_type);
 +      if (ret < 0) {
 +              unregister_chrdev_region(media_dev_t, MEDIA_NUM_DEVICES);
 +              pr_warn("bus_register failed\n");
 +              return -EIO;
 +      }
 +
 +      return 0;
 +}
 +
 +static void __exit media_devnode_exit(void)
 +{
 +      bus_unregister(&media_bus_type);
 +      unregister_chrdev_region(media_dev_t, MEDIA_NUM_DEVICES);
 +}
 +
 +subsys_initcall(media_devnode_init);
 +module_exit(media_devnode_exit)
 +
 +MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
 +MODULE_DESCRIPTION("Device node registration for media drivers");
 +MODULE_LICENSE("GPL");
index a998a2e0ea1dc93c37ca5f30baf749940056eb7d,0000000000000000000000000000000000000000..7c429ce98bae66424c7e70a36e3c29166fa17fba
mode 100644,000000..100644
--- /dev/null
@@@ -1,1036 -1,0 +1,1028 @@@
-  *
-  * This program is free software; you can redistribute it and/or modify
-  * it under the terms of the GNU General Public License version 2 as
-  * published by the Free Software Foundation.
-  *
-  * 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.
++// SPDX-License-Identifier: GPL-2.0-only
 +/*
 + * Media entity
 + *
 + * Copyright (C) 2010 Nokia Corporation
 + *
 + * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
 + *         Sakari Ailus <sakari.ailus@iki.fi>
 + */
 +
 +#include <linux/bitmap.h>
 +#include <linux/property.h>
 +#include <linux/slab.h>
 +#include <media/media-entity.h>
 +#include <media/media-device.h>
 +
 +static inline const char *gobj_type(enum media_gobj_type type)
 +{
 +      switch (type) {
 +      case MEDIA_GRAPH_ENTITY:
 +              return "entity";
 +      case MEDIA_GRAPH_PAD:
 +              return "pad";
 +      case MEDIA_GRAPH_LINK:
 +              return "link";
 +      case MEDIA_GRAPH_INTF_DEVNODE:
 +              return "intf-devnode";
 +      default:
 +              return "unknown";
 +      }
 +}
 +
 +static inline const char *intf_type(struct media_interface *intf)
 +{
 +      switch (intf->type) {
 +      case MEDIA_INTF_T_DVB_FE:
 +              return "dvb-frontend";
 +      case MEDIA_INTF_T_DVB_DEMUX:
 +              return "dvb-demux";
 +      case MEDIA_INTF_T_DVB_DVR:
 +              return "dvb-dvr";
 +      case MEDIA_INTF_T_DVB_CA:
 +              return  "dvb-ca";
 +      case MEDIA_INTF_T_DVB_NET:
 +              return "dvb-net";
 +      case MEDIA_INTF_T_V4L_VIDEO:
 +              return "v4l-video";
 +      case MEDIA_INTF_T_V4L_VBI:
 +              return "v4l-vbi";
 +      case MEDIA_INTF_T_V4L_RADIO:
 +              return "v4l-radio";
 +      case MEDIA_INTF_T_V4L_SUBDEV:
 +              return "v4l-subdev";
 +      case MEDIA_INTF_T_V4L_SWRADIO:
 +              return "v4l-swradio";
 +      case MEDIA_INTF_T_V4L_TOUCH:
 +              return "v4l-touch";
 +      default:
 +              return "unknown-intf";
 +      }
 +};
 +
 +__must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum,
 +                                        int idx_max)
 +{
 +      idx_max = ALIGN(idx_max, BITS_PER_LONG);
 +      ent_enum->bmap = kcalloc(idx_max / BITS_PER_LONG, sizeof(long),
 +                               GFP_KERNEL);
 +      if (!ent_enum->bmap)
 +              return -ENOMEM;
 +
 +      bitmap_zero(ent_enum->bmap, idx_max);
 +      ent_enum->idx_max = idx_max;
 +
 +      return 0;
 +}
 +EXPORT_SYMBOL_GPL(__media_entity_enum_init);
 +
 +void media_entity_enum_cleanup(struct media_entity_enum *ent_enum)
 +{
 +      kfree(ent_enum->bmap);
 +}
 +EXPORT_SYMBOL_GPL(media_entity_enum_cleanup);
 +
 +/**
 + *  dev_dbg_obj - Prints in debug mode a change on some object
 + *
 + * @event_name:       Name of the event to report. Could be __func__
 + * @gobj:     Pointer to the object
 + *
 + * Enabled only if DEBUG or CONFIG_DYNAMIC_DEBUG. Otherwise, it
 + * won't produce any code.
 + */
 +static void dev_dbg_obj(const char *event_name,  struct media_gobj *gobj)
 +{
 +#if defined(DEBUG) || defined (CONFIG_DYNAMIC_DEBUG)
 +      switch (media_type(gobj)) {
 +      case MEDIA_GRAPH_ENTITY:
 +              dev_dbg(gobj->mdev->dev,
 +                      "%s id %u: entity '%s'\n",
 +                      event_name, media_id(gobj),
 +                      gobj_to_entity(gobj)->name);
 +              break;
 +      case MEDIA_GRAPH_LINK:
 +      {
 +              struct media_link *link = gobj_to_link(gobj);
 +
 +              dev_dbg(gobj->mdev->dev,
 +                      "%s id %u: %s link id %u ==> id %u\n",
 +                      event_name, media_id(gobj),
 +                      media_type(link->gobj0) == MEDIA_GRAPH_PAD ?
 +                              "data" : "interface",
 +                      media_id(link->gobj0),
 +                      media_id(link->gobj1));
 +              break;
 +      }
 +      case MEDIA_GRAPH_PAD:
 +      {
 +              struct media_pad *pad = gobj_to_pad(gobj);
 +
 +              dev_dbg(gobj->mdev->dev,
 +                      "%s id %u: %s%spad '%s':%d\n",
 +                      event_name, media_id(gobj),
 +                      pad->flags & MEDIA_PAD_FL_SINK   ? "sink " : "",
 +                      pad->flags & MEDIA_PAD_FL_SOURCE ? "source " : "",
 +                      pad->entity->name, pad->index);
 +              break;
 +      }
 +      case MEDIA_GRAPH_INTF_DEVNODE:
 +      {
 +              struct media_interface *intf = gobj_to_intf(gobj);
 +              struct media_intf_devnode *devnode = intf_to_devnode(intf);
 +
 +              dev_dbg(gobj->mdev->dev,
 +                      "%s id %u: intf_devnode %s - major: %d, minor: %d\n",
 +                      event_name, media_id(gobj),
 +                      intf_type(intf),
 +                      devnode->major, devnode->minor);
 +              break;
 +      }
 +      }
 +#endif
 +}
 +
 +void media_gobj_create(struct media_device *mdev,
 +                         enum media_gobj_type type,
 +                         struct media_gobj *gobj)
 +{
 +      BUG_ON(!mdev);
 +
 +      gobj->mdev = mdev;
 +
 +      /* Create a per-type unique object ID */
 +      gobj->id = media_gobj_gen_id(type, ++mdev->id);
 +
 +      switch (type) {
 +      case MEDIA_GRAPH_ENTITY:
 +              list_add_tail(&gobj->list, &mdev->entities);
 +              break;
 +      case MEDIA_GRAPH_PAD:
 +              list_add_tail(&gobj->list, &mdev->pads);
 +              break;
 +      case MEDIA_GRAPH_LINK:
 +              list_add_tail(&gobj->list, &mdev->links);
 +              break;
 +      case MEDIA_GRAPH_INTF_DEVNODE:
 +              list_add_tail(&gobj->list, &mdev->interfaces);
 +              break;
 +      }
 +
 +      mdev->topology_version++;
 +
 +      dev_dbg_obj(__func__, gobj);
 +}
 +
 +void media_gobj_destroy(struct media_gobj *gobj)
 +{
 +      /* Do nothing if the object is not linked. */
 +      if (gobj->mdev == NULL)
 +              return;
 +
 +      dev_dbg_obj(__func__, gobj);
 +
 +      gobj->mdev->topology_version++;
 +
 +      /* Remove the object from mdev list */
 +      list_del(&gobj->list);
 +
 +      gobj->mdev = NULL;
 +}
 +
 +/*
 + * TODO: Get rid of this.
 + */
 +#define MEDIA_ENTITY_MAX_PADS         512
 +
 +int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
 +                         struct media_pad *pads)
 +{
 +      struct media_device *mdev = entity->graph_obj.mdev;
 +      unsigned int i;
 +
 +      if (num_pads >= MEDIA_ENTITY_MAX_PADS)
 +              return -E2BIG;
 +
 +      entity->num_pads = num_pads;
 +      entity->pads = pads;
 +
 +      if (mdev)
 +              mutex_lock(&mdev->graph_mutex);
 +
 +      for (i = 0; i < num_pads; i++) {
 +              pads[i].entity = entity;
 +              pads[i].index = i;
 +              if (mdev)
 +                      media_gobj_create(mdev, MEDIA_GRAPH_PAD,
 +                                      &entity->pads[i].graph_obj);
 +      }
 +
 +      if (mdev)
 +              mutex_unlock(&mdev->graph_mutex);
 +
 +      return 0;
 +}
 +EXPORT_SYMBOL_GPL(media_entity_pads_init);
 +
 +/* -----------------------------------------------------------------------------
 + * Graph traversal
 + */
 +
 +static struct media_entity *
 +media_entity_other(struct media_entity *entity, struct media_link *link)
 +{
 +      if (link->source->entity == entity)
 +              return link->sink->entity;
 +      else
 +              return link->source->entity;
 +}
 +
 +/* push an entity to traversal stack */
 +static void stack_push(struct media_graph *graph,
 +                     struct media_entity *entity)
 +{
 +      if (graph->top == MEDIA_ENTITY_ENUM_MAX_DEPTH - 1) {
 +              WARN_ON(1);
 +              return;
 +      }
 +      graph->top++;
 +      graph->stack[graph->top].link = entity->links.next;
 +      graph->stack[graph->top].entity = entity;
 +}
 +
 +static struct media_entity *stack_pop(struct media_graph *graph)
 +{
 +      struct media_entity *entity;
 +
 +      entity = graph->stack[graph->top].entity;
 +      graph->top--;
 +
 +      return entity;
 +}
 +
 +#define link_top(en)  ((en)->stack[(en)->top].link)
 +#define stack_top(en) ((en)->stack[(en)->top].entity)
 +
 +/**
 + * media_graph_walk_init - Allocate resources for graph walk
 + * @graph: Media graph structure that will be used to walk the graph
 + * @mdev: Media device
 + *
 + * Reserve resources for graph walk in media device's current
 + * state. The memory must be released using
 + * media_graph_walk_free().
 + *
 + * Returns error on failure, zero on success.
 + */
 +__must_check int media_graph_walk_init(
 +      struct media_graph *graph, struct media_device *mdev)
 +{
 +      return media_entity_enum_init(&graph->ent_enum, mdev);
 +}
 +EXPORT_SYMBOL_GPL(media_graph_walk_init);
 +
 +/**
 + * media_graph_walk_cleanup - Release resources related to graph walking
 + * @graph: Media graph structure that was used to walk the graph
 + */
 +void media_graph_walk_cleanup(struct media_graph *graph)
 +{
 +      media_entity_enum_cleanup(&graph->ent_enum);
 +}
 +EXPORT_SYMBOL_GPL(media_graph_walk_cleanup);
 +
 +void media_graph_walk_start(struct media_graph *graph,
 +                          struct media_entity *entity)
 +{
 +      media_entity_enum_zero(&graph->ent_enum);
 +      media_entity_enum_set(&graph->ent_enum, entity);
 +
 +      graph->top = 0;
 +      graph->stack[graph->top].entity = NULL;
 +      stack_push(graph, entity);
 +      dev_dbg(entity->graph_obj.mdev->dev,
 +              "begin graph walk at '%s'\n", entity->name);
 +}
 +EXPORT_SYMBOL_GPL(media_graph_walk_start);
 +
 +static void media_graph_walk_iter(struct media_graph *graph)
 +{
 +      struct media_entity *entity = stack_top(graph);
 +      struct media_link *link;
 +      struct media_entity *next;
 +
 +      link = list_entry(link_top(graph), typeof(*link), list);
 +
 +      /* The link is not enabled so we do not follow. */
 +      if (!(link->flags & MEDIA_LNK_FL_ENABLED)) {
 +              link_top(graph) = link_top(graph)->next;
 +              dev_dbg(entity->graph_obj.mdev->dev,
 +                      "walk: skipping disabled link '%s':%u -> '%s':%u\n",
 +                      link->source->entity->name, link->source->index,
 +                      link->sink->entity->name, link->sink->index);
 +              return;
 +      }
 +
 +      /* Get the entity in the other end of the link . */
 +      next = media_entity_other(entity, link);
 +
 +      /* Has the entity already been visited? */
 +      if (media_entity_enum_test_and_set(&graph->ent_enum, next)) {
 +              link_top(graph) = link_top(graph)->next;
 +              dev_dbg(entity->graph_obj.mdev->dev,
 +                      "walk: skipping entity '%s' (already seen)\n",
 +                      next->name);
 +              return;
 +      }
 +
 +      /* Push the new entity to stack and start over. */
 +      link_top(graph) = link_top(graph)->next;
 +      stack_push(graph, next);
 +      dev_dbg(entity->graph_obj.mdev->dev, "walk: pushing '%s' on stack\n",
 +              next->name);
 +}
 +
 +struct media_entity *media_graph_walk_next(struct media_graph *graph)
 +{
 +      struct media_entity *entity;
 +
 +      if (stack_top(graph) == NULL)
 +              return NULL;
 +
 +      /*
 +       * Depth first search. Push entity to stack and continue from
 +       * top of the stack until no more entities on the level can be
 +       * found.
 +       */
 +      while (link_top(graph) != &stack_top(graph)->links)
 +              media_graph_walk_iter(graph);
 +
 +      entity = stack_pop(graph);
 +      dev_dbg(entity->graph_obj.mdev->dev,
 +              "walk: returning entity '%s'\n", entity->name);
 +
 +      return entity;
 +}
 +EXPORT_SYMBOL_GPL(media_graph_walk_next);
 +
 +int media_entity_get_fwnode_pad(struct media_entity *entity,
 +                              struct fwnode_handle *fwnode,
 +                              unsigned long direction_flags)
 +{
 +      struct fwnode_endpoint endpoint;
 +      unsigned int i;
 +      int ret;
 +
 +      if (!entity->ops || !entity->ops->get_fwnode_pad) {
 +              for (i = 0; i < entity->num_pads; i++) {
 +                      if (entity->pads[i].flags & direction_flags)
 +                              return i;
 +              }
 +
 +              return -ENXIO;
 +      }
 +
 +      ret = fwnode_graph_parse_endpoint(fwnode, &endpoint);
 +      if (ret)
 +              return ret;
 +
 +      ret = entity->ops->get_fwnode_pad(&endpoint);
 +      if (ret < 0)
 +              return ret;
 +
 +      if (ret >= entity->num_pads)
 +              return -ENXIO;
 +
 +      if (!(entity->pads[ret].flags & direction_flags))
 +              return -ENXIO;
 +
 +      return ret;
 +}
 +EXPORT_SYMBOL_GPL(media_entity_get_fwnode_pad);
 +
 +/* -----------------------------------------------------------------------------
 + * Pipeline management
 + */
 +
 +__must_check int __media_pipeline_start(struct media_entity *entity,
 +                                      struct media_pipeline *pipe)
 +{
 +      struct media_device *mdev = entity->graph_obj.mdev;
 +      struct media_graph *graph = &pipe->graph;
 +      struct media_entity *entity_err = entity;
 +      struct media_link *link;
 +      int ret;
 +
 +      if (!pipe->streaming_count++) {
 +              ret = media_graph_walk_init(&pipe->graph, mdev);
 +              if (ret)
 +                      goto error_graph_walk_start;
 +      }
 +
 +      media_graph_walk_start(&pipe->graph, entity);
 +
 +      while ((entity = media_graph_walk_next(graph))) {
 +              DECLARE_BITMAP(active, MEDIA_ENTITY_MAX_PADS);
 +              DECLARE_BITMAP(has_no_links, MEDIA_ENTITY_MAX_PADS);
 +
 +              entity->stream_count++;
 +
 +              if (entity->pipe && entity->pipe != pipe) {
 +                      pr_err("Pipe active for %s. Can't start for %s\n",
 +                              entity->name,
 +                              entity_err->name);
 +                      ret = -EBUSY;
 +                      goto error;
 +              }
 +
 +              entity->pipe = pipe;
 +
 +              /* Already streaming --- no need to check. */
 +              if (entity->stream_count > 1)
 +                      continue;
 +
 +              if (!entity->ops || !entity->ops->link_validate)
 +                      continue;
 +
 +              bitmap_zero(active, entity->num_pads);
 +              bitmap_fill(has_no_links, entity->num_pads);
 +
 +              list_for_each_entry(link, &entity->links, list) {
 +                      struct media_pad *pad = link->sink->entity == entity
 +                                              ? link->sink : link->source;
 +
 +                      /* Mark that a pad is connected by a link. */
 +                      bitmap_clear(has_no_links, pad->index, 1);
 +
 +                      /*
 +                       * Pads that either do not need to connect or
 +                       * are connected through an enabled link are
 +                       * fine.
 +                       */
 +                      if (!(pad->flags & MEDIA_PAD_FL_MUST_CONNECT) ||
 +                          link->flags & MEDIA_LNK_FL_ENABLED)
 +                              bitmap_set(active, pad->index, 1);
 +
 +                      /*
 +                       * Link validation will only take place for
 +                       * sink ends of the link that are enabled.
 +                       */
 +                      if (link->sink != pad ||
 +                          !(link->flags & MEDIA_LNK_FL_ENABLED))
 +                              continue;
 +
 +                      ret = entity->ops->link_validate(link);
 +                      if (ret < 0 && ret != -ENOIOCTLCMD) {
 +                              dev_dbg(entity->graph_obj.mdev->dev,
 +                                      "link validation failed for '%s':%u -> '%s':%u, error %d\n",
 +                                      link->source->entity->name,
 +                                      link->source->index,
 +                                      entity->name, link->sink->index, ret);
 +                              goto error;
 +                      }
 +              }
 +
 +              /* Either no links or validated links are fine. */
 +              bitmap_or(active, active, has_no_links, entity->num_pads);
 +
 +              if (!bitmap_full(active, entity->num_pads)) {
 +                      ret = -ENOLINK;
 +                      dev_dbg(entity->graph_obj.mdev->dev,
 +                              "'%s':%u must be connected by an enabled link\n",
 +                              entity->name,
 +                              (unsigned)find_first_zero_bit(
 +                                      active, entity->num_pads));
 +                      goto error;
 +              }
 +      }
 +
 +      return 0;
 +
 +error:
 +      /*
 +       * Link validation on graph failed. We revert what we did and
 +       * return the error.
 +       */
 +      media_graph_walk_start(graph, entity_err);
 +
 +      while ((entity_err = media_graph_walk_next(graph))) {
 +              /* Sanity check for negative stream_count */
 +              if (!WARN_ON_ONCE(entity_err->stream_count <= 0)) {
 +                      entity_err->stream_count--;
 +                      if (entity_err->stream_count == 0)
 +                              entity_err->pipe = NULL;
 +              }
 +
 +              /*
 +               * We haven't increased stream_count further than this
 +               * so we quit here.
 +               */
 +              if (entity_err == entity)
 +                      break;
 +      }
 +
 +error_graph_walk_start:
 +      if (!--pipe->streaming_count)
 +              media_graph_walk_cleanup(graph);
 +
 +      return ret;
 +}
 +EXPORT_SYMBOL_GPL(__media_pipeline_start);
 +
 +__must_check int media_pipeline_start(struct media_entity *entity,
 +                                    struct media_pipeline *pipe)
 +{
 +      struct media_device *mdev = entity->graph_obj.mdev;
 +      int ret;
 +
 +      mutex_lock(&mdev->graph_mutex);
 +      ret = __media_pipeline_start(entity, pipe);
 +      mutex_unlock(&mdev->graph_mutex);
 +      return ret;
 +}
 +EXPORT_SYMBOL_GPL(media_pipeline_start);
 +
 +void __media_pipeline_stop(struct media_entity *entity)
 +{
 +      struct media_graph *graph = &entity->pipe->graph;
 +      struct media_pipeline *pipe = entity->pipe;
 +
 +      /*
 +       * If the following check fails, the driver has performed an
 +       * unbalanced call to media_pipeline_stop()
 +       */
 +      if (WARN_ON(!pipe))
 +              return;
 +
 +      media_graph_walk_start(graph, entity);
 +
 +      while ((entity = media_graph_walk_next(graph))) {
 +              /* Sanity check for negative stream_count */
 +              if (!WARN_ON_ONCE(entity->stream_count <= 0)) {
 +                      entity->stream_count--;
 +                      if (entity->stream_count == 0)
 +                              entity->pipe = NULL;
 +              }
 +      }
 +
 +      if (!--pipe->streaming_count)
 +              media_graph_walk_cleanup(graph);
 +
 +}
 +EXPORT_SYMBOL_GPL(__media_pipeline_stop);
 +
 +void media_pipeline_stop(struct media_entity *entity)
 +{
 +      struct media_device *mdev = entity->graph_obj.mdev;
 +
 +      mutex_lock(&mdev->graph_mutex);
 +      __media_pipeline_stop(entity);
 +      mutex_unlock(&mdev->graph_mutex);
 +}
 +EXPORT_SYMBOL_GPL(media_pipeline_stop);
 +
 +/* -----------------------------------------------------------------------------
 + * Links management
 + */
 +
 +static struct media_link *media_add_link(struct list_head *head)
 +{
 +      struct media_link *link;
 +
 +      link = kzalloc(sizeof(*link), GFP_KERNEL);
 +      if (link == NULL)
 +              return NULL;
 +
 +      list_add_tail(&link->list, head);
 +
 +      return link;
 +}
 +
 +static void __media_entity_remove_link(struct media_entity *entity,
 +                                     struct media_link *link)
 +{
 +      struct media_link *rlink, *tmp;
 +      struct media_entity *remote;
 +
 +      if (link->source->entity == entity)
 +              remote = link->sink->entity;
 +      else
 +              remote = link->source->entity;
 +
 +      list_for_each_entry_safe(rlink, tmp, &remote->links, list) {
 +              if (rlink != link->reverse)
 +                      continue;
 +
 +              if (link->source->entity == entity)
 +                      remote->num_backlinks--;
 +
 +              /* Remove the remote link */
 +              list_del(&rlink->list);
 +              media_gobj_destroy(&rlink->graph_obj);
 +              kfree(rlink);
 +
 +              if (--remote->num_links == 0)
 +                      break;
 +      }
 +      list_del(&link->list);
 +      media_gobj_destroy(&link->graph_obj);
 +      kfree(link);
 +}
 +
 +int media_get_pad_index(struct media_entity *entity, bool is_sink,
 +                      enum media_pad_signal_type sig_type)
 +{
 +      int i;
 +      bool pad_is_sink;
 +
 +      if (!entity)
 +              return -EINVAL;
 +
 +      for (i = 0; i < entity->num_pads; i++) {
 +              if (entity->pads[i].flags == MEDIA_PAD_FL_SINK)
 +                      pad_is_sink = true;
 +              else if (entity->pads[i].flags == MEDIA_PAD_FL_SOURCE)
 +                      pad_is_sink = false;
 +              else
 +                      continue;       /* This is an error! */
 +
 +              if (pad_is_sink != is_sink)
 +                      continue;
 +              if (entity->pads[i].sig_type == sig_type)
 +                      return i;
 +      }
 +      return -EINVAL;
 +}
 +EXPORT_SYMBOL_GPL(media_get_pad_index);
 +
 +int
 +media_create_pad_link(struct media_entity *source, u16 source_pad,
 +                       struct media_entity *sink, u16 sink_pad, u32 flags)
 +{
 +      struct media_link *link;
 +      struct media_link *backlink;
 +
 +      BUG_ON(source == NULL || sink == NULL);
 +      BUG_ON(source_pad >= source->num_pads);
 +      BUG_ON(sink_pad >= sink->num_pads);
 +
 +      link = media_add_link(&source->links);
 +      if (link == NULL)
 +              return -ENOMEM;
 +
 +      link->source = &source->pads[source_pad];
 +      link->sink = &sink->pads[sink_pad];
 +      link->flags = flags & ~MEDIA_LNK_FL_INTERFACE_LINK;
 +
 +      /* Initialize graph object embedded at the new link */
 +      media_gobj_create(source->graph_obj.mdev, MEDIA_GRAPH_LINK,
 +                      &link->graph_obj);
 +
 +      /* Create the backlink. Backlinks are used to help graph traversal and
 +       * are not reported to userspace.
 +       */
 +      backlink = media_add_link(&sink->links);
 +      if (backlink == NULL) {
 +              __media_entity_remove_link(source, link);
 +              return -ENOMEM;
 +      }
 +
 +      backlink->source = &source->pads[source_pad];
 +      backlink->sink = &sink->pads[sink_pad];
 +      backlink->flags = flags;
 +      backlink->is_backlink = true;
 +
 +      /* Initialize graph object embedded at the new link */
 +      media_gobj_create(sink->graph_obj.mdev, MEDIA_GRAPH_LINK,
 +                      &backlink->graph_obj);
 +
 +      link->reverse = backlink;
 +      backlink->reverse = link;
 +
 +      sink->num_backlinks++;
 +      sink->num_links++;
 +      source->num_links++;
 +
 +      return 0;
 +}
 +EXPORT_SYMBOL_GPL(media_create_pad_link);
 +
 +int media_create_pad_links(const struct media_device *mdev,
 +                         const u32 source_function,
 +                         struct media_entity *source,
 +                         const u16 source_pad,
 +                         const u32 sink_function,
 +                         struct media_entity *sink,
 +                         const u16 sink_pad,
 +                         u32 flags,
 +                         const bool allow_both_undefined)
 +{
 +      struct media_entity *entity;
 +      unsigned function;
 +      int ret;
 +
 +      /* Trivial case: 1:1 relation */
 +      if (source && sink)
 +              return media_create_pad_link(source, source_pad,
 +                                           sink, sink_pad, flags);
 +
 +      /* Worse case scenario: n:n relation */
 +      if (!source && !sink) {
 +              if (!allow_both_undefined)
 +                      return 0;
 +              media_device_for_each_entity(source, mdev) {
 +                      if (source->function != source_function)
 +                              continue;
 +                      media_device_for_each_entity(sink, mdev) {
 +                              if (sink->function != sink_function)
 +                                      continue;
 +                              ret = media_create_pad_link(source, source_pad,
 +                                                          sink, sink_pad,
 +                                                          flags);
 +                              if (ret)
 +                                      return ret;
 +                              flags &= ~(MEDIA_LNK_FL_ENABLED |
 +                                         MEDIA_LNK_FL_IMMUTABLE);
 +                      }
 +              }
 +              return 0;
 +      }
 +
 +      /* Handle 1:n and n:1 cases */
 +      if (source)
 +              function = sink_function;
 +      else
 +              function = source_function;
 +
 +      media_device_for_each_entity(entity, mdev) {
 +              if (entity->function != function)
 +                      continue;
 +
 +              if (source)
 +                      ret = media_create_pad_link(source, source_pad,
 +                                                  entity, sink_pad, flags);
 +              else
 +                      ret = media_create_pad_link(entity, source_pad,
 +                                                  sink, sink_pad, flags);
 +              if (ret)
 +                      return ret;
 +              flags &= ~(MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
 +      }
 +      return 0;
 +}
 +EXPORT_SYMBOL_GPL(media_create_pad_links);
 +
 +void __media_entity_remove_links(struct media_entity *entity)
 +{
 +      struct media_link *link, *tmp;
 +
 +      list_for_each_entry_safe(link, tmp, &entity->links, list)
 +              __media_entity_remove_link(entity, link);
 +
 +      entity->num_links = 0;
 +      entity->num_backlinks = 0;
 +}
 +EXPORT_SYMBOL_GPL(__media_entity_remove_links);
 +
 +void media_entity_remove_links(struct media_entity *entity)
 +{
 +      struct media_device *mdev = entity->graph_obj.mdev;
 +
 +      /* Do nothing if the entity is not registered. */
 +      if (mdev == NULL)
 +              return;
 +
 +      mutex_lock(&mdev->graph_mutex);
 +      __media_entity_remove_links(entity);
 +      mutex_unlock(&mdev->graph_mutex);
 +}
 +EXPORT_SYMBOL_GPL(media_entity_remove_links);
 +
 +static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
 +{
 +      int ret;
 +
 +      /* Notify both entities. */
 +      ret = media_entity_call(link->source->entity, link_setup,
 +                              link->source, link->sink, flags);
 +      if (ret < 0 && ret != -ENOIOCTLCMD)
 +              return ret;
 +
 +      ret = media_entity_call(link->sink->entity, link_setup,
 +                              link->sink, link->source, flags);
 +      if (ret < 0 && ret != -ENOIOCTLCMD) {
 +              media_entity_call(link->source->entity, link_setup,
 +                                link->source, link->sink, link->flags);
 +              return ret;
 +      }
 +
 +      link->flags = flags;
 +      link->reverse->flags = link->flags;
 +
 +      return 0;
 +}
 +
 +int __media_entity_setup_link(struct media_link *link, u32 flags)
 +{
 +      const u32 mask = MEDIA_LNK_FL_ENABLED;
 +      struct media_device *mdev;
 +      struct media_entity *source, *sink;
 +      int ret = -EBUSY;
 +
 +      if (link == NULL)
 +              return -EINVAL;
 +
 +      /* The non-modifiable link flags must not be modified. */
 +      if ((link->flags & ~mask) != (flags & ~mask))
 +              return -EINVAL;
 +
 +      if (link->flags & MEDIA_LNK_FL_IMMUTABLE)
 +              return link->flags == flags ? 0 : -EINVAL;
 +
 +      if (link->flags == flags)
 +              return 0;
 +
 +      source = link->source->entity;
 +      sink = link->sink->entity;
 +
 +      if (!(link->flags & MEDIA_LNK_FL_DYNAMIC) &&
 +          (source->stream_count || sink->stream_count))
 +              return -EBUSY;
 +
 +      mdev = source->graph_obj.mdev;
 +
 +      if (mdev->ops && mdev->ops->link_notify) {
 +              ret = mdev->ops->link_notify(link, flags,
 +                                           MEDIA_DEV_NOTIFY_PRE_LINK_CH);
 +              if (ret < 0)
 +                      return ret;
 +      }
 +
 +      ret = __media_entity_setup_link_notify(link, flags);
 +
 +      if (mdev->ops && mdev->ops->link_notify)
 +              mdev->ops->link_notify(link, flags,
 +                                     MEDIA_DEV_NOTIFY_POST_LINK_CH);
 +
 +      return ret;
 +}
 +EXPORT_SYMBOL_GPL(__media_entity_setup_link);
 +
 +int media_entity_setup_link(struct media_link *link, u32 flags)
 +{
 +      int ret;
 +
 +      mutex_lock(&link->graph_obj.mdev->graph_mutex);
 +      ret = __media_entity_setup_link(link, flags);
 +      mutex_unlock(&link->graph_obj.mdev->graph_mutex);
 +
 +      return ret;
 +}
 +EXPORT_SYMBOL_GPL(media_entity_setup_link);
 +
 +struct media_link *
 +media_entity_find_link(struct media_pad *source, struct media_pad *sink)
 +{
 +      struct media_link *link;
 +
 +      list_for_each_entry(link, &source->entity->links, list) {
 +              if (link->source->entity == source->entity &&
 +                  link->source->index == source->index &&
 +                  link->sink->entity == sink->entity &&
 +                  link->sink->index == sink->index)
 +                      return link;
 +      }
 +
 +      return NULL;
 +}
 +EXPORT_SYMBOL_GPL(media_entity_find_link);
 +
 +struct media_pad *media_entity_remote_pad(const struct media_pad *pad)
 +{
 +      struct media_link *link;
 +
 +      list_for_each_entry(link, &pad->entity->links, list) {
 +              if (!(link->flags & MEDIA_LNK_FL_ENABLED))
 +                      continue;
 +
 +              if (link->source == pad)
 +                      return link->sink;
 +
 +              if (link->sink == pad)
 +                      return link->source;
 +      }
 +
 +      return NULL;
 +
 +}
 +EXPORT_SYMBOL_GPL(media_entity_remote_pad);
 +
 +static void media_interface_init(struct media_device *mdev,
 +                               struct media_interface *intf,
 +                               u32 gobj_type,
 +                               u32 intf_type, u32 flags)
 +{
 +      intf->type = intf_type;
 +      intf->flags = flags;
 +      INIT_LIST_HEAD(&intf->links);
 +
 +      media_gobj_create(mdev, gobj_type, &intf->graph_obj);
 +}
 +
 +/* Functions related to the media interface via device nodes */
 +
 +struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
 +                                              u32 type, u32 flags,
 +                                              u32 major, u32 minor)
 +{
 +      struct media_intf_devnode *devnode;
 +
 +      devnode = kzalloc(sizeof(*devnode), GFP_KERNEL);
 +      if (!devnode)
 +              return NULL;
 +
 +      devnode->major = major;
 +      devnode->minor = minor;
 +
 +      media_interface_init(mdev, &devnode->intf, MEDIA_GRAPH_INTF_DEVNODE,
 +                           type, flags);
 +
 +      return devnode;
 +}
 +EXPORT_SYMBOL_GPL(media_devnode_create);
 +
 +void media_devnode_remove(struct media_intf_devnode *devnode)
 +{
 +      media_remove_intf_links(&devnode->intf);
 +      media_gobj_destroy(&devnode->intf.graph_obj);
 +      kfree(devnode);
 +}
 +EXPORT_SYMBOL_GPL(media_devnode_remove);
 +
 +struct media_link *media_create_intf_link(struct media_entity *entity,
 +                                          struct media_interface *intf,
 +                                          u32 flags)
 +{
 +      struct media_link *link;
 +
 +      link = media_add_link(&intf->links);
 +      if (link == NULL)
 +              return NULL;
 +
 +      link->intf = intf;
 +      link->entity = entity;
 +      link->flags = flags | MEDIA_LNK_FL_INTERFACE_LINK;
 +
 +      /* Initialize graph object embedded at the new link */
 +      media_gobj_create(intf->graph_obj.mdev, MEDIA_GRAPH_LINK,
 +                      &link->graph_obj);
 +
 +      return link;
 +}
 +EXPORT_SYMBOL_GPL(media_create_intf_link);
 +
 +void __media_remove_intf_link(struct media_link *link)
 +{
 +      list_del(&link->list);
 +      media_gobj_destroy(&link->graph_obj);
 +      kfree(link);
 +}
 +EXPORT_SYMBOL_GPL(__media_remove_intf_link);
 +
 +void media_remove_intf_link(struct media_link *link)
 +{
 +      struct media_device *mdev = link->graph_obj.mdev;
 +
 +      /* Do nothing if the intf is not registered. */
 +      if (mdev == NULL)
 +              return;
 +
 +      mutex_lock(&mdev->graph_mutex);
 +      __media_remove_intf_link(link);
 +      mutex_unlock(&mdev->graph_mutex);
 +}
 +EXPORT_SYMBOL_GPL(media_remove_intf_link);
 +
 +void __media_remove_intf_links(struct media_interface *intf)
 +{
 +      struct media_link *link, *tmp;
 +
 +      list_for_each_entry_safe(link, tmp, &intf->links, list)
 +              __media_remove_intf_link(link);
 +
 +}
 +EXPORT_SYMBOL_GPL(__media_remove_intf_links);
 +
 +void media_remove_intf_links(struct media_interface *intf)
 +{
 +      struct media_device *mdev = intf->graph_obj.mdev;
 +
 +      /* Do nothing if the intf is not registered. */
 +      if (mdev == NULL)
 +              return;
 +
 +      mutex_lock(&mdev->graph_mutex);
 +      __media_remove_intf_links(intf);
 +      mutex_unlock(&mdev->graph_mutex);
 +}
 +EXPORT_SYMBOL_GPL(media_remove_intf_links);
Simple merge
Simple merge
index aee1ddc35de4ec47cf3b848455814e7808def186,7ae588e62ed8a509b7414075748c0184d458a36b..90d1a67db7e5f554f8e941e163b87969de850f2d
@@@ -1,4 -1,9 +1,9 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PC Chen <pc.chen@mediatek.com>
+  *         Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #include <media/v4l2-event.h>
  #include <media/v4l2-mem2mem.h>
index a18268694646e9dd7680ed62adbdae86366b125d,3861d4433be917ff7aff19c376b2d359f4b0be0a..e0c5338bde3d3e11aac5bbe5de5fee6870cd9219
@@@ -1,4 -1,9 +1,9 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PC Chen <pc.chen@mediatek.com>
+  *         Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #ifndef _MTK_VCODEC_DEC_H_
  #define _MTK_VCODEC_DEC_H_
index dbe957aa138d2c463a3162ed2b0e133913e05f48,372d378243779e94ff0e47c0db1b1901bb7bce50..00d090df11bbe49361ace483c0070b581e798bdc
@@@ -1,4 -1,9 +1,9 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PC Chen <pc.chen@mediatek.com>
+  *         Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #include <linux/slab.h>
  #include <linux/interrupt.h>
index b09242b1470de7ab26c8f70696817e97f17fe41a,273f78f129da22cd5ce04f7af1bfbf3aae907afb..5a6ec8fb52daab725975ba8094468ae707b17ac4
@@@ -1,4 -1,8 +1,8 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #include <linux/clk.h>
  #include <linux/of_address.h>
index b44621ad15d8482c7bc7e4f99c1f4464e9b95340,74555cc5a893d1e826971edf5ac245548c460099..872d8bf8cfaf3c6f1f20e2df129bf1482986a859
@@@ -1,4 -1,8 +1,8 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #ifndef _MTK_VCODEC_DEC_PM_H_
  #define _MTK_VCODEC_DEC_PM_H_
index 7306aeabe2295a93fa7b273dd1da6168fed93abd,1044176d8e6f3ab13e94682e8c97db32fafcd70e..c1422739dab472af84bc5805985210f8f023e810
@@@ -1,4 -1,9 +1,9 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: PC Chen <pc.chen@mediatek.com>
+ *         Tiffany Lin <tiffany.lin@mediatek.com>
+ */
  
  #ifndef _MTK_VCODEC_DRV_H_
  #define _MTK_VCODEC_DRV_H_
index 67e8a023ef411731280e7fcb6bcf68fa7975b8c9,0cf5744b4c28a1ae547482b02a8e77d11d698848..480cc8fe281a50f520bdf6eda11582da92072678
@@@ -1,4 -1,9 +1,9 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: PC Chen <pc.chen@mediatek.com>
+ *         Tiffany Lin <tiffany.lin@mediatek.com>
+ */
  
  #include <media/v4l2-event.h>
  #include <media/v4l2-mem2mem.h>
index e372e5ddff8ace9423634edcaf257b1ddfe45f37,8248cb628882ce0ce76d61998d1515cd09bdb4d2..a9c9f86b9c8375aa33524c1509401b78b7bc02f7
@@@ -1,4 -1,9 +1,9 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: PC Chen <pc.chen@mediatek.com>
+ *         Tiffany Lin <tiffany.lin@mediatek.com>
+ */
  
  #ifndef _MTK_VCODEC_ENC_H_
  #define _MTK_VCODEC_ENC_H_
index b6d7c602c2adeb66688a6f55de5ee43b6df83bc0,b15e9d2ef6a9d56a2192793b59dfe004060c1fb1..1d82aa2b6017c00ea5168fdf2972fd8d686cced4
@@@ -1,4 -1,9 +1,9 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: PC Chen <pc.chen@mediatek.com>
+ *     Tiffany Lin <tiffany.lin@mediatek.com>
+ */
  
  #include <linux/slab.h>
  #include <linux/interrupt.h>
index 90bdad5c71b03b86e30875662c60dddd61d3ecca,4740ae5e9a8e872631b463e3d7fce74dc83d5108..3e2bfded79a66a1b38e2c0da652f2ca0136ebcc2
@@@ -1,4 -1,8 +1,8 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Tiffany Lin <tiffany.lin@mediatek.com>
+ */
  
  #include <linux/clk.h>
  #include <linux/of_address.h>
index dddbbe02a109d44379e220c63e3a6a37c3fd7608,63165fc1b84a23592d5f42c21b08784034d486a0..b7ecdfd74823bd978bd336f21f3dc9247a856b9c
@@@ -1,4 -1,8 +1,8 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Tiffany Lin <tiffany.lin@mediatek.com>
+ */
  
  #ifndef _MTK_VCODEC_ENC_PM_H_
  #define _MTK_VCODEC_ENC_PM_H_
index 693888e4987fa5850e2932f37ad2dc5880e5100a,f8aae7cc5f575833aeabdc0aceb6a2356b77631b..a3c7a380c9308481256cfd5a97fdfb43050df0dc
@@@ -1,4 -1,8 +1,8 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Tiffany Lin <tiffany.lin@mediatek.com>
+ */
  
  #include <linux/errno.h>
  #include <linux/wait.h>
index 55f046cd93a581b3f7bc0767e491665714ea49d7,ba632528fa72a9f4c6ae4448648239a14bd23198..638cd1f3526af6b5754e82759375dfc486b94584
@@@ -1,4 -1,8 +1,8 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: Tiffany Lin <tiffany.lin@mediatek.com>
+ */
  
  #ifndef _MTK_VCODEC_INTR_H_
  #define _MTK_VCODEC_INTR_H_
index e1a9ac9694e3daf07fb393995fc2833fb0ff5b87,13f7061bfb50c9d88e8ef64a8a51d64820c576e8..d48f542db1a914dc7c4ee321b368df9f9febc364
@@@ -1,4 -1,9 +1,9 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: PC Chen <pc.chen@mediatek.com>
+ *     Tiffany Lin <tiffany.lin@mediatek.com>
+ */
  
  #include <linux/module.h>
  
index daabb63548d07c319c859d21f18250c7de71922e,677adb990e288f6fac4fe02e433c8a43a25ba6c4..b999d7b84ed18d0d6bf753758ec89137f42e8e08
@@@ -1,4 -1,9 +1,9 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+ * Copyright (c) 2016 MediaTek Inc.
+ * Author: PC Chen <pc.chen@mediatek.com>
+ *     Tiffany Lin <tiffany.lin@mediatek.com>
+ */
  
  #ifndef _MTK_VCODEC_UTIL_H_
  #define _MTK_VCODEC_UTIL_H_
index d725ea54b1c1011f021ac8ebdb37ad34cdb4469d,455dbe4887c175dfc74b1d6e47c6c8ff574837be..c035f744b1f127e2586339b0aa875e2d9dab3d3f
@@@ -1,4 -1,8 +1,8 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PC Chen <pc.chen@mediatek.com>
+  */
  
  #include <linux/module.h>
  #include <linux/slab.h>
index 8de997875b6b4d91fb7cb914e17beab1b002468c,91139cef6283e880780726c6568cbf18f31c6904..24f976f0d477f2542289cce5657fd3fcdd42d0f7
@@@ -1,4 -1,9 +1,9 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: Jungchang Tsao <jungchang.tsao@mediatek.com>
+  *       PC Chen <pc.chen@mediatek.com>
+  */
  
  #include <linux/slab.h>
  #include "../vdec_drv_if.h"
index 02b65298c87e2850aa003164152727fb7c276b94,c1904ad5e69bec373584c7ee60b54721d249869d..9e6b630d7f5ba3c86e3797e9e9a5b60cb538d4ef
@@@ -1,4 -1,10 +1,10 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: Daniel Hsiao <daniel.hsiao@mediatek.com>
+  *    Kai-Sean Yang <kai-sean.yang@mediatek.com>
+  *    Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #include <linux/fs.h>
  #include <linux/slab.h>
index 014712b1312e1681188e06729a90db5e8c71a25d,b6cb922fc40084a0351959977d0da12631b61062..2019aec71ddb753bed19eca9d4ca45dc8ef074e9
@@@ -1,4 -1,8 +1,8 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PC Chen <pc.chen@mediatek.com>
+  */
  
  #ifndef _VDEC_DRV_BASE_
  #define _VDEC_DRV_BASE_
index 6835cb7d090a45366675e0a0512833804bc3ca4a,5c98a76a77b7de56876fc568a3d0e4829027e4a1..bd42d9028c420a49f9626849e39301bc9fb62686
@@@ -1,4 -1,9 +1,9 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PC Chen <pc.chen@mediatek.com>
+  *         Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #include <linux/interrupt.h>
  #include <linux/kernel.h>
index ceba7f55a526c7aa6744e0ba683fa60303b0a5b2,409623574145f19f3294d77902854c04ead6e7d9..c5bd8b0dbe13d7c3cbdf17b1e2a1bccac109554f
@@@ -1,4 -1,9 +1,9 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PC Chen <pc.chen@mediatek.com>
+  *               Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #ifndef _VDEC_DRV_IF_H_
  #define _VDEC_DRV_IF_H_
index 6370f1285a6312ac4c161d0cdf6e63183481ab32,b05dcdeb77341992ee9738766fd8150b502a4d06..47a1c1c0fd0426e25be23e9a27d8bf6fa2f54250
@@@ -1,4 -1,8 +1,8 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PC Chen <pc.chen@mediatek.com>
+  */
  
  #ifndef _VDEC_IPI_MSG_H_
  #define _VDEC_IPI_MSG_H_
index 9b240d325a84ffb4fa5fd223d8d3c37c9cc63b44,035ba917ed0e5fd24cf19f7045fd94a3e2ff4646..3f38cc4509efbf0b3f28fce74c6788f61fe10c54
@@@ -1,4 -1,8 +1,8 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PC Chen <pc.chen@mediatek.com>
+  */
  
  #include "mtk_vcodec_drv.h"
  #include "mtk_vcodec_util.h"
index 3c417493ccca83e8e1fddf53a88bb5fce592cf73,6701778ea5d97f49e4971e264d7ea22a646aefc0..b76f717e4fd71aa2d524ebe51ed039332fb18a3f
@@@ -1,4 -1,8 +1,8 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PC Chen <pc.chen@mediatek.com>
+  */
  
  #ifndef _VDEC_VPU_IF_H_
  #define _VDEC_VPU_IF_H_
index 0cf08dd7b6e3b2e9ef53e268065e2227b5285c25,3125eaf2a3263dd3fdb1b666b7bc4af90cfd0e8e..21f2eaea207b9287c1c49d514616e6af7ed13103
@@@ -1,4 -1,10 +1,10 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: Jungchang Tsao <jungchang.tsao@mediatek.com>
+  *         Daniel Hsiao <daniel.hsiao@mediatek.com>
+  *         PoChun Lin <pochun.lin@mediatek.com>
+  */
  
  #include <linux/interrupt.h>
  #include <linux/kernel.h>
index 3fb9e0c79b4f8f96133661a49e23a1bbaf219b2d,ba19cdc4e4f150bae26cbb88f6136a5823c9f440..81f87f6ec4355f4d168dfe8437422e0d9ad67bab
@@@ -1,4 -1,9 +1,9 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: Daniel Hsiao <daniel.hsiao@mediatek.com>
+  *         PoChun Lin <pochun.lin@mediatek.com>
+  */
  
  #include <linux/interrupt.h>
  #include <linux/kernel.h>
index 2de37b47fe7343073bcd9fad7062e0366d7987f1,81620683b94f92da2ae41482f1a7e40b4fcb5c55..09968a68db4205879df19cd5bd993f0940e4276b
@@@ -1,4 -1,10 +1,10 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: Daniel Hsiao <daniel.hsiao@mediatek.com>
+  *    Jungchang Tsao <jungchang.tsao@mediatek.com>
+  *    Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #ifndef _VENC_DRV_BASE_
  #define _VENC_DRV_BASE_
index 25c1e100f5a1a3bcdcde6c91592f589deb4c0112,608c08b2ab8f77a0ef5519b739f23f6e9e3e14e4..600c43c17e48b7dfeeecea401a3068a9f4ec7281
@@@ -1,4 -1,10 +1,10 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: Daniel Hsiao <daniel.hsiao@mediatek.com>
+  *    Jungchang Tsao <jungchang.tsao@mediatek.com>
+  *    Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #include <linux/interrupt.h>
  #include <linux/kernel.h>
index d6605812ebb017112e2bfe09a5050f49364b1f44,bbba1cec7be433f511546724e4cb47afb0a4ef6d..cc5bb36c273515040ded10ba726337aa6dfa074e
@@@ -1,4 -1,10 +1,10 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: Daniel Hsiao <daniel.hsiao@mediatek.com>
+  *            Jungchang Tsao <jungchang.tsao@mediatek.com>
+  *            Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #ifndef _VENC_DRV_IF_H_
  #define _VENC_DRV_IF_H_
index d5282f24f9349d2772fe201faf42e16d36b94c76,be34780760f4341ab6d44a04215c2b165346bd13..28ee04ca62412a4f7977cd57263301696bcd5df6
@@@ -1,4 -1,10 +1,10 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: Jungchang Tsao <jungchang.tsao@mediatek.com>
+  *       Daniel Hsiao <daniel.hsiao@mediatek.com>
+  *       Tiffany Lin <tiffany.lin@mediatek.com>
+  */
  
  #ifndef _VENC_IPI_MSG_H_
  #define _VENC_IPI_MSG_H_
index a6906db747180a1bef963107435fc5d7c0cacd80,7daf8694c62e2f2219c64e2ed25fcb296f814148..3e931b0ed09650b36314b2ed03e07c63c2f01afe
@@@ -1,4 -1,8 +1,8 @@@
 -// SPDX-License-Identifier: GPL-2.0-only
 +// SPDX-License-Identifier: GPL-2.0
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PoChun Lin <pochun.lin@mediatek.com>
+  */
  
  #include "mtk_vpu.h"
  #include "venc_ipi_msg.h"
index fd4f85646aa52ff403998f80e55e9ceb248b0588,a6b6d0eafb50479b4d22151413afc6a226cd1e19..ba301a138a5afaa2a2614bda0a4826f3e6f09572
@@@ -1,4 -1,8 +1,8 @@@
 -/* SPDX-License-Identifier: GPL-2.0-only */
 +/* SPDX-License-Identifier: GPL-2.0 */
+ /*
+  * Copyright (c) 2016 MediaTek Inc.
+  * Author: PoChun Lin <pochun.lin@mediatek.com>
+  */
  
  #ifndef _VENC_VPU_IF_H_
  #define _VENC_VPU_IF_H_
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index cc61315b675c4769429c3d80556fe72ccc88c54d,8039ba4ebf6805bee70fe7cbce0c3749b2892245..bac0778f7defc1c653762def3f777d7294518bcc
   * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
   * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
   * Copyright (C) 2006, 2007 Chris Pascoe (c.pascoe@itee.uq.edu.au)
 + * Copyright (C) 2011, 2017 Maciej S. Szmigiero (mail@maciej.szmigiero.name)
   *
-  *   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, version 2.
-  *
   * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
   */
  #include <media/tuner.h>
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge