int find_subdev_mipi(struct decon_device *decon) { struct exynos_md *md; if (decon->id && decon->pdata->dsi_mode == DSI_MODE_SINGLE) { decon_err("failed to get subdev of dsim\n"); return -EINVAL; } md = (struct exynos_md *)module_name_to_driver_data(MDEV_MODULE_NAME); if (!md) { decon_err("failed to get mdev device(%d)\n", decon->id); return -ENODEV; } decon->output_sd = md->dsim_sd[decon->id]; decon->out_type = DECON_OUT_DSI; if (IS_ERR_OR_NULL(decon->output_sd)) decon_warn("couldn't find dsim%d subdev\n", decon->id); v4l2_subdev_call(decon->output_sd, core, ioctl, DSIM_IOC_GET_LCD_INFO, NULL); decon->lcd_info = (struct decon_lcd *)v4l2_get_subdev_hostdata(decon->output_sd); if (IS_ERR_OR_NULL(decon->lcd_info)) { decon_err("failed to get lcd information\n"); return -EINVAL; } return 0; }
static int hdmi_register_entity(struct hdmi_device *hdev) { struct v4l2_subdev *sd = &hdev->sd; struct v4l2_device *v4l2_dev; struct media_pad *pads = &hdev->pad; struct media_entity *me = &sd->entity; struct device *dev = hdev->dev; struct exynos_md *md; int ret; dev_dbg(dev, "HDMI entity init\n"); /* init hdmi subdev */ v4l2_subdev_init(sd, &hdmi_sd_ops); sd->owner = THIS_MODULE; strlcpy(sd->name, "s5p-hdmi", sizeof(sd->name)); dev_set_drvdata(dev, sd); /* init hdmi sub-device as entity */ pads[HDMI_PAD_SINK].flags = MEDIA_PAD_FL_SINK; me->ops = &hdmi_entity_ops; ret = media_entity_init(me, HDMI_PADS_NUM, pads, 0); if (ret) { dev_err(dev, "failed to initialize media entity\n"); return ret; } /* get output media ptr for registering hdmi's sd */ md = (struct exynos_md *)module_name_to_driver_data(MDEV_MODULE_NAME); if (!md) { dev_err(dev, "failed to get output media device\n"); return -ENODEV; } v4l2_dev = &md->v4l2_dev; /* regiser HDMI subdev as entity to v4l2_dev pointer of * output media device */ ret = v4l2_device_register_subdev(v4l2_dev, sd); if (ret) { dev_err(dev, "failed to register HDMI subdev\n"); return ret; } return 0; }
int find_subdev_hdmi(struct decon_device *decon) { struct v4l2_subdev *output_sd; output_sd = (struct v4l2_subdev *)module_name_to_driver_data("s5p-hdmi"); if (!output_sd) { decon_err("failed to get hdmi device\n"); return -ENODEV; } decon->output_sd = output_sd; decon->out_type = DECON_OUT_HDMI; decon_info("%s entity get successfully\n", output_sd->name); return 0; }
int __devinit mxr_acquire_video(struct mxr_device *mdev, struct mxr_output_conf *output_conf, int output_count) { int i; int ret = 0; struct v4l2_subdev *sd; struct s5p_mxr_platdata *pdata = mdev->pdata; mdev->alloc_ctx = mdev->vb2->init(mdev); if (IS_ERR_OR_NULL(mdev->alloc_ctx)) { mxr_err(mdev, "could not acquire vb2 allocator\n"); ret = PTR_ERR(mdev->alloc_ctx); goto fail; } if (is_ip_ver_5r) { exynos_create_iovmm(mdev->dev, 1, 0); iovmm_reserve(mdev->dev, MXR_VA, MXR_VA); } else { exynos_create_iovmm(mdev->dev, 3, 0); } /* registering outputs */ mdev->output_cnt = 0; for (i = 0; i < output_count; ++i) { struct mxr_output_conf *conf = &output_conf[i]; struct mxr_output *out; /* find subdev of output devices */ sd = (struct v4l2_subdev *) module_name_to_driver_data(conf->module_name); /* trying to register next output */ if (sd == NULL) continue; out = kzalloc(sizeof *out, GFP_KERNEL); if (out == NULL) { mxr_err(mdev, "no memory for '%s'\n", conf->output_name); ret = -ENOMEM; /* registered subdevs are removed in fail_v4l2_dev */ goto fail_output; } strlcpy(out->name, conf->output_name, sizeof(out->name)); out->sd = sd; out->cookie = conf->cookie; mdev->output[mdev->output_cnt++] = out; mxr_info(mdev, "added output '%s' from module '%s'\n", conf->output_name, conf->module_name); /* checking if maximal number of outputs is reached */ if (mdev->output_cnt >= MXR_MAX_OUTPUTS) break; } if (mdev->output_cnt == 0) { mxr_err(mdev, "failed to register any output\n"); ret = -ENODEV; /* skipping fail_output because there is nothing to free */ goto fail_vb2_allocator; } return 0; fail_output: /* kfree is NULL-safe */ for (i = 0; i < mdev->output_cnt; ++i) kfree(mdev->output[i]); memset(mdev->output, 0, sizeof mdev->output); fail_vb2_allocator: /* freeing allocator context */ mdev->vb2->cleanup(mdev->alloc_ctx); fail: return ret; }