Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59ecd59d authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

[media] omap3/omap4/davinci: get rid of MEDIA_ENT_T_V4L2_SUBDEV abuse



On omap3/omap4/davinci drivers, MEDIA_ENT_T_V4L2_SUBDEV macro is
abused in order to "simplify" the pad checks.

Basically, it does a logical or of this macro, in order to check
for a local index and if the entity is either a subdev or not.

As we'll get rid of MEDIA_ENT_T_V4L2_SUBDEV macro, replace it by
2 << 16 where it occurs, and add a note saying that the code
there is actually a hack.

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 3efdf62c
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -2513,9 +2513,14 @@ static int ccdc_link_setup(struct media_entity *entity,
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
	struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd);
	struct isp_device *isp = to_isp_device(ccdc);
	struct isp_device *isp = to_isp_device(ccdc);
	int index = local->index;


	switch (local->index | media_entity_type(remote->entity)) {
	/* FIXME: this is actually a hack! */
	case CCDC_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV:
	if (is_media_entity_v4l2_subdev(remote->entity))
		index |= 2 << 16;

	switch (index) {
	case CCDC_PAD_SINK | 2 << 16:
		/* Read from the sensor (parallel interface), CCP2, CSI2a or
		/* Read from the sensor (parallel interface), CCP2, CSI2a or
		 * CSI2c.
		 * CSI2c.
		 */
		 */
@@ -2543,7 +2548,7 @@ static int ccdc_link_setup(struct media_entity *entity,
	 * Revisit this when it will be implemented, and return -EBUSY for now.
	 * Revisit this when it will be implemented, and return -EBUSY for now.
	 */
	 */


	case CCDC_PAD_SOURCE_VP | MEDIA_ENT_T_V4L2_SUBDEV:
	case CCDC_PAD_SOURCE_VP | 2 << 16:
		/* Write to preview engine, histogram and H3A. When none of
		/* Write to preview engine, histogram and H3A. When none of
		 * those links are active, the video port can be disabled.
		 * those links are active, the video port can be disabled.
		 */
		 */
@@ -2556,7 +2561,7 @@ static int ccdc_link_setup(struct media_entity *entity,
		}
		}
		break;
		break;


	case CCDC_PAD_SOURCE_OF | MEDIA_ENT_T_DEVNODE:
	case CCDC_PAD_SOURCE_OF:
		/* Write to memory */
		/* Write to memory */
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (ccdc->output & ~CCDC_OUTPUT_MEMORY)
			if (ccdc->output & ~CCDC_OUTPUT_MEMORY)
@@ -2567,7 +2572,7 @@ static int ccdc_link_setup(struct media_entity *entity,
		}
		}
		break;
		break;


	case CCDC_PAD_SOURCE_OF | MEDIA_ENT_T_V4L2_SUBDEV:
	case CCDC_PAD_SOURCE_OF | 2 << 16:
		/* Write to resizer */
		/* Write to resizer */
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (ccdc->output & ~CCDC_OUTPUT_RESIZER)
			if (ccdc->output & ~CCDC_OUTPUT_RESIZER)
+9 −4
Original line number Original line Diff line number Diff line
@@ -956,9 +956,14 @@ static int ccp2_link_setup(struct media_entity *entity,
{
{
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd);
	struct isp_ccp2_device *ccp2 = v4l2_get_subdevdata(sd);
	int index = local->index;


	switch (local->index | media_entity_type(remote->entity)) {
	/* FIXME: this is actually a hack! */
	case CCP2_PAD_SINK | MEDIA_ENT_T_DEVNODE:
	if (is_media_entity_v4l2_subdev(remote->entity))
		index |= 2 << 16;

	switch (index) {
	case CCP2_PAD_SINK:
		/* read from memory */
		/* read from memory */
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (ccp2->input == CCP2_INPUT_SENSOR)
			if (ccp2->input == CCP2_INPUT_SENSOR)
@@ -970,7 +975,7 @@ static int ccp2_link_setup(struct media_entity *entity,
		}
		}
		break;
		break;


	case CCP2_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV:
	case CCP2_PAD_SINK | 2 << 16:
		/* read from sensor/phy */
		/* read from sensor/phy */
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (ccp2->input == CCP2_INPUT_MEMORY)
			if (ccp2->input == CCP2_INPUT_MEMORY)
@@ -981,7 +986,7 @@ static int ccp2_link_setup(struct media_entity *entity,
				ccp2->input = CCP2_INPUT_NONE;
				ccp2->input = CCP2_INPUT_NONE;
		} break;
		} break;


	case CCP2_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV:
	case CCP2_PAD_SOURCE | 2 << 16:
		/* write to video port/ccdc */
		/* write to video port/ccdc */
		if (flags & MEDIA_LNK_FL_ENABLED)
		if (flags & MEDIA_LNK_FL_ENABLED)
			ccp2->output = CCP2_OUTPUT_CCDC;
			ccp2->output = CCP2_OUTPUT_CCDC;
+8 −3
Original line number Original line Diff line number Diff line
@@ -1144,14 +1144,19 @@ static int csi2_link_setup(struct media_entity *entity,
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
	struct isp_csi2_device *csi2 = v4l2_get_subdevdata(sd);
	struct isp_csi2_ctrl_cfg *ctrl = &csi2->ctrl;
	struct isp_csi2_ctrl_cfg *ctrl = &csi2->ctrl;
	int index = local->index;


	/*
	/*
	 * The ISP core doesn't support pipelines with multiple video outputs.
	 * The ISP core doesn't support pipelines with multiple video outputs.
	 * Revisit this when it will be implemented, and return -EBUSY for now.
	 * Revisit this when it will be implemented, and return -EBUSY for now.
	 */
	 */


	switch (local->index | media_entity_type(remote->entity)) {
	/* FIXME: this is actually a hack! */
	case CSI2_PAD_SOURCE | MEDIA_ENT_T_DEVNODE:
	if (is_media_entity_v4l2_subdev(remote->entity))
		index |= 2 << 16;

	switch (index) {
	case CSI2_PAD_SOURCE:
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (csi2->output & ~CSI2_OUTPUT_MEMORY)
			if (csi2->output & ~CSI2_OUTPUT_MEMORY)
				return -EBUSY;
				return -EBUSY;
@@ -1161,7 +1166,7 @@ static int csi2_link_setup(struct media_entity *entity,
		}
		}
		break;
		break;


	case CSI2_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV:
	case CSI2_PAD_SOURCE | 2 << 16:
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (csi2->output & ~CSI2_OUTPUT_CCDC)
			if (csi2->output & ~CSI2_OUTPUT_CCDC)
				return -EBUSY;
				return -EBUSY;
+10 −5
Original line number Original line Diff line number Diff line
@@ -2144,9 +2144,14 @@ static int preview_link_setup(struct media_entity *entity,
{
{
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
	struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
	int index = local->index;


	switch (local->index | media_entity_type(remote->entity)) {
	/* FIXME: this is actually a hack! */
	case PREV_PAD_SINK | MEDIA_ENT_T_DEVNODE:
	if (is_media_entity_v4l2_subdev(remote->entity))
		index |= 2 << 16;

	switch (index) {
	case PREV_PAD_SINK:
		/* read from memory */
		/* read from memory */
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (prev->input == PREVIEW_INPUT_CCDC)
			if (prev->input == PREVIEW_INPUT_CCDC)
@@ -2158,7 +2163,7 @@ static int preview_link_setup(struct media_entity *entity,
		}
		}
		break;
		break;


	case PREV_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV:
	case PREV_PAD_SINK | 2 << 16:
		/* read from ccdc */
		/* read from ccdc */
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (prev->input == PREVIEW_INPUT_MEMORY)
			if (prev->input == PREVIEW_INPUT_MEMORY)
@@ -2175,7 +2180,7 @@ static int preview_link_setup(struct media_entity *entity,
	 * Revisit this when it will be implemented, and return -EBUSY for now.
	 * Revisit this when it will be implemented, and return -EBUSY for now.
	 */
	 */


	case PREV_PAD_SOURCE | MEDIA_ENT_T_DEVNODE:
	case PREV_PAD_SOURCE:
		/* write to memory */
		/* write to memory */
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (prev->output & ~PREVIEW_OUTPUT_MEMORY)
			if (prev->output & ~PREVIEW_OUTPUT_MEMORY)
@@ -2186,7 +2191,7 @@ static int preview_link_setup(struct media_entity *entity,
		}
		}
		break;
		break;


	case PREV_PAD_SOURCE | MEDIA_ENT_T_V4L2_SUBDEV:
	case PREV_PAD_SOURCE | 2 << 16:
		/* write to resizer */
		/* write to resizer */
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (prev->output & ~PREVIEW_OUTPUT_RESIZER)
			if (prev->output & ~PREVIEW_OUTPUT_RESIZER)
+9 −4
Original line number Original line Diff line number Diff line
@@ -1623,9 +1623,14 @@ static int resizer_link_setup(struct media_entity *entity,
{
{
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct isp_res_device *res = v4l2_get_subdevdata(sd);
	struct isp_res_device *res = v4l2_get_subdevdata(sd);
	int index = local->index;


	switch (local->index | media_entity_type(remote->entity)) {
	/* FIXME: this is actually a hack! */
	case RESZ_PAD_SINK | MEDIA_ENT_T_DEVNODE:
	if (is_media_entity_v4l2_subdev(remote->entity))
		index |= 2 << 16;

	switch (index) {
	case RESZ_PAD_SINK:
		/* read from memory */
		/* read from memory */
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (res->input == RESIZER_INPUT_VP)
			if (res->input == RESIZER_INPUT_VP)
@@ -1637,7 +1642,7 @@ static int resizer_link_setup(struct media_entity *entity,
		}
		}
		break;
		break;


	case RESZ_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV:
	case RESZ_PAD_SINK | 2 << 16:
		/* read from ccdc or previewer */
		/* read from ccdc or previewer */
		if (flags & MEDIA_LNK_FL_ENABLED) {
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (res->input == RESIZER_INPUT_MEMORY)
			if (res->input == RESIZER_INPUT_MEMORY)
@@ -1649,7 +1654,7 @@ static int resizer_link_setup(struct media_entity *entity,
		}
		}
		break;
		break;


	case RESZ_PAD_SOURCE | MEDIA_ENT_T_DEVNODE:
	case RESZ_PAD_SOURCE:
		/* resizer always write to memory */
		/* resizer always write to memory */
		break;
		break;


Loading