Skip to content
  • Helen Koike's avatar
    media: staging: rkisp1: cap: refactor enable/disable stream to allow multistreaming · 7d93fa0b
    Helen Koike authored
    
    
    Allow streaming from self picture path and main picture path at the same
    time.
    
    Take care for s_stream() callbacks to not be called twice.
    When starting a stream, s_stream(true) shouldn't be called for the isp
    and the sensor if the other stream is already enabled (since it was
    already called).
    When stopping a stream, s_stream(false) shouldn't be called for isp and
    the sensor if the other stream is still enabled.
    
    Remove the callback function scheme for navigating through the topology,
    simplifying the code, improving readability.
    
    Remove multistreaming item from the TODO list.
    
    Signed-off-by: default avatarHelen Koike <helen.koike@collabora.com>
    ---
    
    Hello,
    
    Since we didn't reach an agreement on the helpers in the core[1], I'm
    sending this patch to fix this limitation only for rkisp1.
    
    [1] https://patchwork.linuxtv.org/project/linux-media/cover/20200415013044.1778572-1-helen.koike@collabora.com/
    
    If we decide to add the helpers in the future, we can clean up drivers
    even more, but I don't want to block this feature.
    
    This Patch depends on patch:
    "media: staging: rkisp1: validate links before powering and streaming"
    https://patchwork.linuxtv.org/project/linux-media/patch/20201002184222.7094-2-dafna.hirschfeld@collabora.com/
    
    Changes in V2:
    ==============
    - Rebase on top of patch
    "media: staging: rkisp1: validate links before powering and streaming"
    which fixes media_pipeline_{start,stop}() calling order.
    - Fix commit message
    - Fix disable order
    - Disable capture when s_stream(true) of the resizer fails
    
    Overview of the patch:
    ======================
    
    * Rename rkisp1_stream_{start,stop}() to
      rkisp1_cap_stream_{enable,disable}() to clarify the difference between
      other stream enable/disable functions
    
    * Implement rkisp1_pipeline_stream_{enable,disable}() to replace
      rkisp1_pipeline_{enable,disable}_cb() and rkisp1_pipeline_sink_walk(),
      which were removed.
    
    * Call rkisp1_cap_stream_{enable,disable}() from
      rkisp1_pipeline_stream_{enable,disable}() for better
      unwind handling and function name semantics.
    
    * Remove item from TODO list (I also reviewed the use of the
      is_streaming var in the code and lgtm).
    
    This patch was tested on rockpi4 board with:
    ============================================
    
    "media-ctl" "-d" "platform:rkisp1" "-r"
    "media-ctl" "-d" "platform:rkisp1" "-l" "'imx219 4-0010':0 -> 'rkisp1_isp':0 [1]"
    "media-ctl" "-d" "platform:rkisp1" "-l" "'rkisp1_isp':2 -> 'rkisp1_resizer_selfpath':0 [1]"
    "media-ctl" "-d" "platform:rkisp1" "-l" "'rkisp1_isp':2 -> 'rkisp1_resizer_mainpath':0 [1]"
    
    "media-ctl" "-d" "platform:rkisp1" "--set-v4l2" '"imx219 4-0010":0 [fmt:SRGGB10_1X10/1640x1232]'
    
    "media-ctl" "-d" "platform:rkisp1" "--set-v4l2" '"rkisp1_isp":0 [fmt:SRGGB10_1X10/1640x1232 crop: (0,0)/1600x1200]'
    "media-ctl" "-d" "platform:rkisp1" "--set-v4l2" '"rkisp1_isp":2 [fmt:YUYV8_2X8/1600x1200 crop: (0,0)/1500x1100]'
    
    "media-ctl" "-d" "platform:rkisp1" "--set-v4l2" '"rkisp1_resizer_selfpath":0 [fmt:YUYV8_2X8/1500x1100 crop: (300,400)/1400x1000]'
    "media-ctl" "-d" "platform:rkisp1" "--set-v4l2" '"rkisp1_resizer_selfpath":1 [fmt:YUYV8_2X8/900x800]'
    
    "v4l2-ctl" "-z" "platform:rkisp1" "-d" "rkisp1_selfpath" "-v" "width=900,height=800,"
    "v4l2-ctl" "-z" "platform:rkisp1" "-d" "rkisp1_selfpath" "-v" "pixelformat=422P"
    
    "media-ctl" "-d" "platform:rkisp1" "--set-v4l2" '"rkisp1_resizer_mainpath":0 [fmt:YUYV8_2X8/1500x1100 crop: (300,400)/1400x1000]'
    "media-ctl" "-d" "platform:rkisp1" "--set-v4l2" '"rkisp1_resizer_mainpath":1 [fmt:YUYV8_2X8/900x800]'
    
    "v4l2-ctl" "-z" "platform:rkisp1" "-d" "rkisp1_mainpath" "-v" "width=900,height=800,"
    "v4l2-ctl" "-z" "platform:rkisp1" "-d" "rkisp1_mainpath" "-v" "pixelformat=422P"
    
    sleep 1
    
    time v4l2-ctl "-z" "platform:rkisp1" "-d" "rkisp1_mainpath" "--stream-mmap" "--stream-count" "100" &
    time v4l2-ctl "-z" "platform:rkisp1" "-d" "rkisp1_selfpath" "--stream-mmap" "--stream-count" "100" &
    
    wait
    echo "Completed"
    
    Thanks
    Helen
    7d93fa0b