diff options
Diffstat (limited to 'drivers/media/video/s5p-fimc/fimc-mdevice.c')
-rw-r--r-- | drivers/media/video/s5p-fimc/fimc-mdevice.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/media/video/s5p-fimc/fimc-mdevice.c b/drivers/media/video/s5p-fimc/fimc-mdevice.c index 6753c45631b8..52cef4865423 100644 --- a/drivers/media/video/s5p-fimc/fimc-mdevice.c +++ b/drivers/media/video/s5p-fimc/fimc-mdevice.c | |||
@@ -193,9 +193,13 @@ int __fimc_pipeline_shutdown(struct fimc_pipeline *p) | |||
193 | 193 | ||
194 | int fimc_pipeline_shutdown(struct fimc_pipeline *p) | 194 | int fimc_pipeline_shutdown(struct fimc_pipeline *p) |
195 | { | 195 | { |
196 | struct media_entity *me = &p->subdevs[IDX_SENSOR]->entity; | 196 | struct media_entity *me; |
197 | int ret; | 197 | int ret; |
198 | 198 | ||
199 | if (!p || !p->subdevs[IDX_SENSOR]) | ||
200 | return -EINVAL; | ||
201 | |||
202 | me = &p->subdevs[IDX_SENSOR]->entity; | ||
199 | mutex_lock(&me->parent->graph_mutex); | 203 | mutex_lock(&me->parent->graph_mutex); |
200 | ret = __fimc_pipeline_shutdown(p); | 204 | ret = __fimc_pipeline_shutdown(p); |
201 | mutex_unlock(&me->parent->graph_mutex); | 205 | mutex_unlock(&me->parent->graph_mutex); |
@@ -498,12 +502,12 @@ static void fimc_md_unregister_entities(struct fimc_md *fmd) | |||
498 | * @source: the source entity to create links to all fimc entities from | 502 | * @source: the source entity to create links to all fimc entities from |
499 | * @sensor: sensor subdev linked to FIMC[fimc_id] entity, may be null | 503 | * @sensor: sensor subdev linked to FIMC[fimc_id] entity, may be null |
500 | * @pad: the source entity pad index | 504 | * @pad: the source entity pad index |
501 | * @fimc_id: index of the fimc device for which link should be enabled | 505 | * @link_mask: bitmask of the fimc devices for which link should be enabled |
502 | */ | 506 | */ |
503 | static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, | 507 | static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, |
504 | struct media_entity *source, | 508 | struct media_entity *source, |
505 | struct v4l2_subdev *sensor, | 509 | struct v4l2_subdev *sensor, |
506 | int pad, int fimc_id) | 510 | int pad, int link_mask) |
507 | { | 511 | { |
508 | struct fimc_sensor_info *s_info; | 512 | struct fimc_sensor_info *s_info; |
509 | struct media_entity *sink; | 513 | struct media_entity *sink; |
@@ -520,7 +524,7 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, | |||
520 | if (!fmd->fimc[i]->variant->has_cam_if) | 524 | if (!fmd->fimc[i]->variant->has_cam_if) |
521 | continue; | 525 | continue; |
522 | 526 | ||
523 | flags = (i == fimc_id) ? MEDIA_LNK_FL_ENABLED : 0; | 527 | flags = ((1 << i) & link_mask) ? MEDIA_LNK_FL_ENABLED : 0; |
524 | 528 | ||
525 | sink = &fmd->fimc[i]->vid_cap.subdev.entity; | 529 | sink = &fmd->fimc[i]->vid_cap.subdev.entity; |
526 | ret = media_entity_create_link(source, pad, sink, | 530 | ret = media_entity_create_link(source, pad, sink, |
@@ -552,7 +556,10 @@ static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, | |||
552 | if (!fmd->fimc_lite[i]) | 556 | if (!fmd->fimc_lite[i]) |
553 | continue; | 557 | continue; |
554 | 558 | ||
555 | flags = (i == fimc_id) ? MEDIA_LNK_FL_ENABLED : 0; | 559 | if (link_mask & (1 << (i + FIMC_MAX_DEVS))) |
560 | flags = MEDIA_LNK_FL_ENABLED; | ||
561 | else | ||
562 | flags = 0; | ||
556 | 563 | ||
557 | sink = &fmd->fimc_lite[i]->subdev.entity; | 564 | sink = &fmd->fimc_lite[i]->subdev.entity; |
558 | ret = media_entity_create_link(source, pad, sink, | 565 | ret = media_entity_create_link(source, pad, sink, |
@@ -614,9 +621,8 @@ static int fimc_md_create_links(struct fimc_md *fmd) | |||
614 | struct s5p_fimc_isp_info *pdata; | 621 | struct s5p_fimc_isp_info *pdata; |
615 | struct fimc_sensor_info *s_info; | 622 | struct fimc_sensor_info *s_info; |
616 | struct media_entity *source, *sink; | 623 | struct media_entity *source, *sink; |
617 | int i, pad, fimc_id = 0; | 624 | int i, pad, fimc_id = 0, ret = 0; |
618 | int ret = 0; | 625 | u32 flags, link_mask = 0; |
619 | u32 flags; | ||
620 | 626 | ||
621 | for (i = 0; i < fmd->num_sensors; i++) { | 627 | for (i = 0; i < fmd->num_sensors; i++) { |
622 | if (fmd->sensor[i].subdev == NULL) | 628 | if (fmd->sensor[i].subdev == NULL) |
@@ -668,19 +674,20 @@ static int fimc_md_create_links(struct fimc_md *fmd) | |||
668 | if (source == NULL) | 674 | if (source == NULL) |
669 | continue; | 675 | continue; |
670 | 676 | ||
677 | link_mask = 1 << fimc_id++; | ||
671 | ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, | 678 | ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, |
672 | pad, fimc_id++); | 679 | pad, link_mask); |
673 | } | 680 | } |
674 | 681 | ||
675 | fimc_id = 0; | ||
676 | for (i = 0; i < ARRAY_SIZE(fmd->csis); i++) { | 682 | for (i = 0; i < ARRAY_SIZE(fmd->csis); i++) { |
677 | if (fmd->csis[i].sd == NULL) | 683 | if (fmd->csis[i].sd == NULL) |
678 | continue; | 684 | continue; |
679 | source = &fmd->csis[i].sd->entity; | 685 | source = &fmd->csis[i].sd->entity; |
680 | pad = CSIS_PAD_SOURCE; | 686 | pad = CSIS_PAD_SOURCE; |
681 | 687 | ||
688 | link_mask = 1 << fimc_id++; | ||
682 | ret = __fimc_md_create_fimc_sink_links(fmd, source, NULL, | 689 | ret = __fimc_md_create_fimc_sink_links(fmd, source, NULL, |
683 | pad, fimc_id++); | 690 | pad, link_mask); |
684 | } | 691 | } |
685 | 692 | ||
686 | /* Create immutable links between each FIMC's subdev and video node */ | 693 | /* Create immutable links between each FIMC's subdev and video node */ |
@@ -734,8 +741,8 @@ static void fimc_md_put_clocks(struct fimc_md *fmd) | |||
734 | } | 741 | } |
735 | 742 | ||
736 | static int __fimc_md_set_camclk(struct fimc_md *fmd, | 743 | static int __fimc_md_set_camclk(struct fimc_md *fmd, |
737 | struct fimc_sensor_info *s_info, | 744 | struct fimc_sensor_info *s_info, |
738 | bool on) | 745 | bool on) |
739 | { | 746 | { |
740 | struct s5p_fimc_isp_info *pdata = s_info->pdata; | 747 | struct s5p_fimc_isp_info *pdata = s_info->pdata; |
741 | struct fimc_camclk_info *camclk; | 748 | struct fimc_camclk_info *camclk; |
@@ -744,12 +751,10 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd, | |||
744 | if (WARN_ON(pdata->clk_id >= FIMC_MAX_CAMCLKS) || fmd == NULL) | 751 | if (WARN_ON(pdata->clk_id >= FIMC_MAX_CAMCLKS) || fmd == NULL) |
745 | return -EINVAL; | 752 | return -EINVAL; |
746 | 753 | ||
747 | if (s_info->clk_on == on) | ||
748 | return 0; | ||
749 | camclk = &fmd->camclk[pdata->clk_id]; | 754 | camclk = &fmd->camclk[pdata->clk_id]; |
750 | 755 | ||
751 | dbg("camclk %d, f: %lu, clk: %p, on: %d", | 756 | dbg("camclk %d, f: %lu, use_count: %d, on: %d", |
752 | pdata->clk_id, pdata->clk_frequency, camclk, on); | 757 | pdata->clk_id, pdata->clk_frequency, camclk->use_count, on); |
753 | 758 | ||
754 | if (on) { | 759 | if (on) { |
755 | if (camclk->use_count > 0 && | 760 | if (camclk->use_count > 0 && |
@@ -760,11 +765,9 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd, | |||
760 | clk_set_rate(camclk->clock, pdata->clk_frequency); | 765 | clk_set_rate(camclk->clock, pdata->clk_frequency); |
761 | camclk->frequency = pdata->clk_frequency; | 766 | camclk->frequency = pdata->clk_frequency; |
762 | ret = clk_enable(camclk->clock); | 767 | ret = clk_enable(camclk->clock); |
768 | dbg("Enabled camclk %d: f: %lu", pdata->clk_id, | ||
769 | clk_get_rate(camclk->clock)); | ||
763 | } | 770 | } |
764 | s_info->clk_on = 1; | ||
765 | dbg("Enabled camclk %d: f: %lu", pdata->clk_id, | ||
766 | clk_get_rate(camclk->clock)); | ||
767 | |||
768 | return ret; | 771 | return ret; |
769 | } | 772 | } |
770 | 773 | ||
@@ -773,7 +776,6 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd, | |||
773 | 776 | ||
774 | if (--camclk->use_count == 0) { | 777 | if (--camclk->use_count == 0) { |
775 | clk_disable(camclk->clock); | 778 | clk_disable(camclk->clock); |
776 | s_info->clk_on = 0; | ||
777 | dbg("Disabled camclk %d", pdata->clk_id); | 779 | dbg("Disabled camclk %d", pdata->clk_id); |
778 | } | 780 | } |
779 | return ret; | 781 | return ret; |
@@ -789,8 +791,6 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd, | |||
789 | * devices to which sensors can be attached, either directly or through | 791 | * devices to which sensors can be attached, either directly or through |
790 | * the MIPI CSI receiver. The clock is allowed here to be used by | 792 | * the MIPI CSI receiver. The clock is allowed here to be used by |
791 | * multiple sensors concurrently if they use same frequency. | 793 | * multiple sensors concurrently if they use same frequency. |
792 | * The per sensor subdev clk_on attribute helps to synchronize accesses | ||
793 | * to the sclk_cam clocks from the video and media device nodes. | ||
794 | * This function should only be called when the graph mutex is held. | 794 | * This function should only be called when the graph mutex is held. |
795 | */ | 795 | */ |
796 | int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on) | 796 | int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on) |