SlideShare a Scribd company logo
1 of 51
Download to read offline
The World Leader in High Performance Signal Processing Solutions




    Rapid Development of a
Blackfin-based Video Application

              Presented By:
              Glen Ouellette
About this Module


    This module discusses the rapid development process of a
    Blackfin® Video application using readily available and fully
    supported software and hardware modules.

    It is recommended that users have some understanding of:
     ! Basic knowledge of software terminology
     ! Experience in embedded systems

     ! Blackfin System Services and Device Drivers




2
Module Outline

! Video-In
    "   Refresher on Device Driver
    "   Video Capture using ADV7183B Video Decoder

! Video-Out
    "   Video Display using ADV7179 Video Encoder

! Video      Compression
    " Overview of MJPEG offering
    " Encoding Video Data


! USB
    " Blackfin USB-LAN EZ-Extender
    " Blackfin-Host data transfer over USB 2.0


! Rapid      Develeopment of a MJPEG Encode
3
Outline of Video-In Sub-module

!A   short Device Driver refresher

! Simple   Video Capture using ADV7183B Video Decoder




4
Device Driver Refresher

! Standardized            API
    " User interface is the same across all device drivers
     ! Independent of driver

         "   Allows buffers to be passed from driver to driver
     !   Independent of processor
         "   Does not require change when moving from BF561 to BF537
! DeviceDrivers are Totally Independent
! User Application provides buffers to device driver
    " Provided to driver via adi_dev_Read() or adi_dev_Write()
     ! Inbound buffers – Filled with data received from the device

     ! Outbound buffers – Contain data to send out through the device




5
Device Driver Refresher (continued)

! Application        involvement
    " Initialize   services
! Independent         Device drivers manage their own set of system
    services
    " Drivers call into system services as required
     ! Video In Device Driver (e.g. ADV7183B)

       " Calls into DMA Manager
       " Calls into Interrupt Manager             Application
       " Calls into Timer Control
                                                   Video In                       Video Out
       " Calls into DCB                          Device Driver                   Device Driver



                                                                     USB
                                                                 Device Driver



                                               System Services

6
Additional Information on Device Drivers

! Device  Drivers and System Services Manual for Blackfin
    Processors
       − http://www.analog.com/processors/manuals
! Device    Drivers and System Services Addendum (Sept 2005)
       − ftp://ftp.analog.com/pub/tools/patches/Blackfin/VDSP++4.0/




7
Video-In Data Flows

! Video      Decoder is configured to accept source input
    " NTSC or PAL
    " Example: ADV7183B with NTSC input

! Hardware
    " ADSP-BF561      EZ-Kit (Silicon Revision 0.3 or higher)
     !   Has onboard ADV7183B Video Decoder
! ADV7183B          Device Driver provided with VisualDSP++
    " Others
                                      ADSP-BF561
                                                            Video_Frames[0]
                                                                  Blanking

                                                                  Field 1
                                                                Active Video
                                     PPI0




                         ADV7183B           FILL FRAME 0         Blanking      Process
                          Decoder                                 Field 2
     Video Source                                               Active Video
                                                                 Blanking




                                                       Video Frame Stored in SDRAM
8
Double Buffering

! Double       Buffering is typical in Video Applications
    " Benefit
     ! Pass data into a single frame while processing/displaying data elements of a
       previously filled frame
     ! Avoids over writing unprocessed pixels/frames

    " Often   Multiple Buffering (6 or more)
                                        ADSP-BF561
                                                                   Video_Frames[0]
                                                                        Blanking
                                                                        Field 1
                                                                      Active Video
                                                                        Blanking
                                                              E0                      Process
                                                          R AM          Field 2
                                                     LF               Active Video
                                               FIL
                                                                        Blanking
                                       PPI0




                         ADV7183B                                  Video_Frames[1]
                                              FIL
                          Decoder                   LF
                                                         RA
                                                                         Blanking
     Video Source                                          ME            Field 1
                                                              1        Active Video
                                                                        Blanking      Process
                                                                         Field 2
                                                                       Active Video
                                                                        Blanking


9
Dataflow Method: Chaining with Loopback

! Chaining       with Loopback
     " Device  driver automatically loops back to the first buffer after the
       last buffer in the chain is processed
     " Application doesn’t need to resupply buffers
      ! Lower overhead
      ! Device driver never “starves” for data

                           ADSP-BF561
                                                      Video_Frames[0]
                                                           Blanking
                                                           Field 1
                                                         Active Video
                                                  0       Blanking
                                               ME
                                           F RA            Field 2
                                       L                 Active Video
                                   FIL
                                                          Blanking
                           PPI0




                ADV7183B                              Video_Frames[1]
                 Decoder          FIL                      Blanking     Video_Frames[0]   Video_Frames[1]
                                        LF
                                             RA            Field 1
                                               ME        Active Video
                                                  1
                                                           Blanking
                                                           Field 2
                                                         Active Video
                                                           Blanking



10
Video-In Programming Sequence

! Initialize
          System Services
! Good practice to reset Video Decoder
     " OnBlackfin EZ-Kits, ADV7183B Reset is controlled via
      Programmable Flag
! Open      ADV7183B Device Driver
     " ‘AD7183DriverHandle’
     " Configure for Inbound traffic from ADV7183B to Video Buffer
     " PPI_Callback_In
                       ezErrorCheck(adi_dev_Open(DeviceManagerHandle,
                                      &ADIAD7183EntryPoint,        // pdd entry point
                                      0,                           // device instance
                                      NULL,                        // client handle callback identifier
                                      &AD7183DriverHandle,         // DevMgr handle for this device
                                      ADI_DEV_DIRECTION_INBOUND,// data direction for this device
                                      DMAManagerHandle,            // handle to DmaMgr for this device
                                      DCBManagerHandle,            // handle to deferred callback service
                                      PPI_Callback_In));           // deferred callback

                       /********* open AD7183 via PPI0 ****************************************/
                       ezErrorCheck(adi_dev_Control(AD7183DriverHandle, ADI_AD7183_CMD_OPEN_PPI, (void *)0));




11
Video-In Programming Sequence (cont’d)
                                              /******** ADV7183 Inbound Buffers******************/
                                              In1_Buffer2D.Data = Video_Frames[0];
                                              In1_Buffer2D.ElementWidth = sizeof(u16);
                                              In1_Buffer2D.XCount = (1716/2);

! Allocate     two 2D_Buffers                 In1_Buffer2D.XModify = 2;
                                              In1_Buffer2D.YCount = 525;
                                              In1_Buffer2D.YModify = 2;
 " In1_Buffer2D,   In2_Buffer2D               In1_Buffer2D.CallbackParameter = 1;
                                              In1_Buffer2D.pNext = &In2_Buffer2D;
! Pointer    to the data                      In2_Buffer2D.Data = Video_Frames[1];
 " Video_Frames[0]    and Video_Frames[1]     In2_Buffer2D.ElementWidth = sizeof(u16);
                                              In2_Buffer2D.XCount = (1716/2);
! Element     width                           In2_Buffer2D.XModify = 2;
                                              In2_Buffer2D.YCount = 525;
 " 16-bit   wide element                      In2_Buffer2D.YModify = 2;
                                              In2_Buffer2D.CallbackParameter = 2;
                                              In2_Buffer2D.pNext = NULL;
! XCount,     XModify, YCount, YModify
 " ITU-R    BT656 NTSC Video Frame
! Callback     parameter
 " For   this example, ‘1’ indicates Video_Frames[0] and ‘2’ indicates
     Video_Frame[1]
! pNext
 " Pointer   to the next Video_Frame buffer in the chain (NULL if the
     last Video_Frame buffer in chain)

12
Then Enable Dataflow Sequence

! Start   Capturing Video Data from PPI0 into Video_Frames[0] and
     Video_Frame[1]
     "   adi_dev_Control(AD7183DriverHandle, ADI_DEV_CMD_SET_DATAFLOW, (void*)TRUE));




                                            ADSP-BF561               Video_Frames[0]
                                                                           Blanking
                                                                           Field 1
                                                                         Active Video
                                                                 0         Blanking
                                                              ME
                                                            RA             Field 2
                                                     LF                  Active Video
                                                 FIL
                                     PPI0




                        ADV7183B                                           Blanking
                         Decoder                 FIL
                                                       LF
                                                                     Video_Frames[1]
                                                            RA             Blanking
                                                              ME
                                                                 1         Field 1
                                                                         Active Video
                                                                           Blanking
                                                                           Field 2
                                                                         Active Video
                                                                           Blanking




13
Programming Sequence for ADV7183B

                                Open ADV7183 driver for Inbound dataflow




                   Configure ADV7183 driver for chained loopback, ITU-R BT656 mode etc.




                                                                                             ADV7183B Driver
                                  Provide 2 frame buffers for driver to fill
     Application




                                               Enable dataflow




                                         Driver makes callback when frame buffer is filled




                           Callback function provides next buffer for driver to fill




14
Outline for Video-Out Sub-module

! Simple   Video Display using ADV7179 Video Encoder




15
Video-Out Data Flows

! Video       Encoder is configured to drive display
     " NTSC or PAL
     " Example: ADV7179 connected to NTSC TV

! Hardware
     " ADSP-BF561            EZ-Kit (Silicon Revision 0.3 or higher)
      !   Has onboard ADV7179 Video Encoder
! ADV7179          Device Driver provided with VisualDSP++

                                                         ADSP-BF561

                          Video_Frames[0]
                               Blanking
                                Field 1
                              Active Video
                                                                      PPI1




              Processed        Blanking      Display FRAME 0                 ADV7179
                                Field 2
                              Active Video
                                                                             Encoder
                               Blanking


                  Video Frame Stored in SDRAM




16
Double Buffering

! Double  Buffering is typical in Video Applications
! Benefits
     ! Display a single frame while filling data elements of a previously
       displayed filled frame
     ! Avoids over displaying old pixels/frames

                                                         ADSP-BF561
                      Video_Frames[0]
                           Blanking
                            Field 1
                          Active Video   Di
                                           sp
                           Blanking          lay
          Processed                                FR
                            Field 2                     AM
                          Active Video                     E
                           Blanking
                                                               0
                                                                             ADV7179
                                                                      PPI1


                      Video_Frames[1]
                           Blanking
                                                                             Encoder
                                                               1
                            Field 1                      ME
                          Active Video                 RA
                                                  yF
          Processed        Blanking
                                             ispla
                            Field 2      D
                          Active Video
                           Blanking




17
Dataflow Method: Chaining with Loopback

! Chaining          with Loopback
     " Device driver automatically loops back to the first buffer after the
      last buffer in the chain is processed
! Application            does not need to re-supply buffers
     " Lower overhead
     " Device driver never “starves” for data

                                                                              ADSP-BF561
                                           Video_Frames[0]
                                                 Blanking

                                                  Field 1
                                                Active Video   Di
                                                                 sp
                                                 Blanking          lay
                                                                          FR
                                                  Field 2
                                                Active Video
                                                                            AM
                                                                               E   0
        Video_Frame[0]    Video_Frame[1]         Blanking
                                                                                                  ADV7179




                                                                                           PPI1
                                           Video_Frames[1]                                        Encoder
                                                 Blanking
                                                                                    1
                                                  Field 1                      ME
                                                Active Video                 RA
                                                                          yF
                                                 Blanking           pla
                                                  Field 2       Dis
                                                Active Video

                                                 Blanking




18
Video-Out Programming Sequence

! Initialize
          System Services
! Good practice to reset Video Encoder
     " OnBlackfin EZ-Kits, ADV7179 Reset is controlled via
      Programmable Flag
! Open      ADV7179 Device Driver
     " ‘AD7179DriverHandle’
     " Configure for Outbound traffic from Video Buffer to ADV7179
     " PPI_Callback_Out
                   ezErrorCheck(adi_dev_Open( DeviceManagerHandle,
                                  &ADIADV717xEntryPoint,      // Device Entry point
                                  0,                          // Device number
                                  NULL,                       // No client handle
                                  &AD7179DriverHandle,        // Device manager handle address
                                  ADI_DEV_DIRECTION_OUTBOUND, // Data Direction
                                  DMAManagerHandle,           // Handle to DMA Manager
                                  DCBManagerHandle,           // Handle to callback manager
                                  PPI_Callback_Out));         // deferred callback

                   /********* open AD7179 via PPI1 ****************************************
                   ezErrorCheck(adi_dev_Control( AD7179DriverHandle, ADI_ADV717x_CMD_SET_PPI_DEVICE_NUMBER, (void*)1 ));



19
Video-Out Programming Sequence – Cont’d
                                             /******** AD7179 Outbound Buffers*******************/
                                             Out1_Buffer2D.Data = Video_Frames[0];
                                             Out1_Buffer2D.ElementWidth = sizeof(u16);
                                             Out1_Buffer2D.XCount = (1716/2);
                                             Out1_Buffer2D.XModify = 2;
! Allocate    two 2D_Buffers                 Out1_Buffer2D.YCount = 525;
                                             Out1_Buffer2D.YModify = 2;
 " Out1_Buffer2D,    Out2_Buffer2D           Out1_Buffer2D.CallbackParameter = 1;
                                             Out1_Buffer2D.pNext = &Out2_Buffer2D;

! Pointer   to the data                      Out2_Buffer2D.Data = Video_Frames[1];
                                             Out2_Buffer2D.ElementWidth = sizeof(u16);
 " Video_Frames[0]    and Video_Frames[1]    Out2_Buffer2D.XCount = (1716/2);
                                             Out2_Buffer2D.XModify = 2;
! Element    width                           Out2_Buffer2D.YCount = 525;
                                             Out2_Buffer2D.YModify = 2;
                                             Out2_Buffer2D.CallbackParameter = 2;
 " 16-bit   wide element                     Out2_Buffer2D.pNext = NULL;

! XCount,    XModify, YCount, YModify
 " ITU-R   BT656 NTSC Video Frame = 1716 Bytes per line by 525 lines
     per Frame
! Callback    parameter
 " For   this example, ‘1’ indicates Video_Frame[0] and ‘2’ indicates
     Video_Frame[1]
! pNext
 " Pointer   to the next Video_Frame buffer in the chain (NULL if the
     last Video_Frame buffer in chain)

20
Then Enable Dataflow Sequence

! Start   Displaying Video Data from Video_Frames[0] and
     Video_Frames[1] into PPI1
     "   adi_dev_Control(AD7179DriverHandle, ADI_DEV_CMD_SET_DATAFLOW, (void*)TRUE));




                                                           ADSP-BF561
                        Video_Frames[0]
                             Blanking
                              Field 1
                            Active Video   Di
                                             sp
                             Blanking          lay
                              Field 2
                                                     FR
                            Active Video
                                                          AM
                                                             E   0
                             Blanking
                                                                               ADV7179

                                                                        PPI1
                        Video_Frames[1]                                        Encoder
                             Blanking
                                                                 1
                              Field 1                      ME
                            Active Video             F   RA
                                               lay
                                             sp
                             Blanking
                              Field 2      Di
                            Active Video
                             Blanking




21
Programming Sequence for ADV7179

                               Open ADV7179 driver for Outbound dataflow




                   Configure ADV7179 driver for chained loopback, ITU-R BT656 mode etc.




                                                                                               ADV7179 Driver
                               Provide 2 frame buffers for driver to send out
     Application




                                              Enable dataflow




                                   Driver makes callback when frame buffer has been sent out




                        Callback function provides next buffer for driver to send out




22
Recap: Video-In and Video-Out

! Installed       ADV7183B Device Driver
     " Video    Decoder is configured to accept source input
! Installed       ADV7179 Device Driver
     " Video    Encoder is configured to drive display
! Independent               Drivers, but can share Video Frame Buffers

                                    ADSP-BF561          Video_Frames[0]     Video_Frames[0]                     ADSP-BF561
                                                             Blanking            Blanking
                                                              Field 1             Field 1
                                                            Active Video        Active Video   Di
                                                                                                 sp
                                                                                                   lay
                                                 E0
                                                             Blanking            Blanking
                                                                                                         FR
                                              AM
                                                              Field 2             Field 2
 Video Source                                                                                              AM
                                           FR
                                                            Active Video        Active Video
                                         L                                                                    E   0
                                       FIL
                                                             Blanking            Blanking
                             PPI0




                 ADV7183B




                                                                                                                             PPI1
                  Decoder                              Video_Frames[1]     Video_Frames[1]                                          ADV7179
                                      FIL
                                          LF                 Blanking            Blanking                             1             Encoder
                                            RA                Field 1             Field 1                        ME
                                              ME            Active Video        Active Video
                                                                                                           F   RA
                                                   1                                                   y
                                                             Blanking            Blanking
                                                                                                   pla
                                                              Field 2
                                                            Active Video
                                                                                  Field 2      Dis
                                                                                Active Video
                                                             Blanking            Blanking




23
Recap: Rapid Development of Video Pass
Through
!    Reuse Video Frame buffers to create Simple Video Pass
     Through
     " Only    1 Frame Delay between input and output


                                         ADSP-BF561             Video_Frames[0]
                                                                      Blanking
                                                                       Field 1
                                                                     Active Video   Di
                                                                                      sp
                                                                                        lay
                                                        E0
                                                                      Blanking

                                                    M                  Field 2                FR
                                                  RA                 Active Video               AM
                                                LF                                                 E     0
                                            FIL
                                                                      Blanking
                                  PPI0




                                                                                                              PPI1
                       ADV7183B                                                                                      ADV7179
                        Decoder                                Video_Frames[1]
                                           FIL                                                                       Encoder
                                                 LF                                                      E1
                                                                      Blanking
                                                   RA                  Field 1
                                                                                                    AM
                                                     ME              Active Video
                                                                                                  FR
                                                          1                                   y
                                                                      Blanking
                                                                                          pla
                                                                       Field 2        Dis
                                                                     Active Video
                                                                      Blanking

                                                              Video Frames in SDRAM




Quick Tips:
     "   Map video frames into different banks of SDRAM to avoid latencies
     "   Configure DMA traffic control to optimize unidirectional traffic and reduce SDRAM
         bus turnaround penalties
24
Recap: Beyond Pass Through - Video
Processing
! Simple        Video Pass Through is common
     " E.g.   Back-up Video Camera, Side-view Mirrors, Back seat monitor
! Often,   Inbound Frames are processed/compressed by
     software codecs
     " E.g.   Sobel Edge detection, MJPEG Encoding, MPEG Encoding
                                       ADSP-BF561                Video_Frames[0]
                                                                       Blanking
                                                                        Field 1
                                                                      Active Video   Di
                                                                                       sp
                                                    0                  Blanking          lay
                                                 ME                     Field 2                FR
                                               RA                     Active Video               AM
                                             LF                                                     E      0
                                          FIL
                                                                       Blanking
                                PPI0




                                                                                                                    PPI1
                     ADV7183B                                                                                              ADV7179
                      Decoder                                   Video_Frames[1]
                                         FIL                                                                               Encoder
                                             L                         Blanking                             1
                                                 FR
                                                    AM                                                   ME
                                                                                                       RA
                                                                        Field 1
                                                       E              Active Video
                                                                                               y   F
                                                           1           Blanking
                                                                                           pla
                                                                        Field 2        Dis
                                                                      Active Video
                                                                       Blanking

                                                               Video Frames in SDRAM




                                                                                                        Compressed
                                                                                                           Video



                                                                 MJPEG
                                                                 Encoder
                                                                                                           Memory




25
Outline for Encoding Video Data Sub-
module
! Overview   of the MJPEG offering

! Encoding   Video Data




26
Overview of the MJPEG offering

! JPEG/MJPEG   SDK includes stand alone Encoder and Decoder
  Libraries
  " http://www.analog.com/blackfin/codeExamples
  " Access to all source code, except the actual encoder and decoder
    algorithm (libraries provided)
  " Examples based entirely on ADI’s System Services and Device
    Driver libraries
! Other Resources
  " ITU-T, “Information Technology- Digital Compression and Coding
    of Continuous-Tone Still Images- Requirements and Guidelines”,
  " ADI, “JPEG Encoder Library Developer's Guide”
  " ADI, “JPEG Decoder Library Developer's Guide”
  " ADI, “MJPEG AVI Library Developer’s Guide”




27
MJPEG Encoding Video Data Basics
! An       Inbound buffer is processed/compressed by MJPEG codec
     "   MJPEG Codec Encodes a 4:2:0 Video buffer comprised of Y, Cr, Cb
         Buffers
                                                                                      Compressed
                                                                                         Video


                                           Y
                                                                   MJPEG
                                                                   Encoder
                               Cr              Cb




!    Memory DMA is often used to separate and down sample 4:2:2 interlaced
     image to a progressive YCrCb 4:2:0 format
     "   Down sampling the Cr and Cb components by two in the vertical direction
     "   Callback typically initiates Memory DMA action

                        Video_Frames[0]
                             Blanking
                              Field 1
                                                                         Y
                            Active Video
                                                                                  MJPEG
                             Blanking          MemoryDMA Y/Cr/Cb
                              Field 2                                             Encoder
                            Active Video                            Cr       Cb
                             Blanking


                        4:2:2 Format                                                               Compressed
                                                                   4:2:0 Format                       Video




28
Initializing MJPEG Codec
! Configure                   MJPEG Codec
     "   JPEG_FRAME_WIDTH, JPEG_FRAME_HEIGHT, JPEG_QUALITYFACTOR,
         etc.
                                                                      Quality        Compression
             Horizontal          Vertical        Frames/Sec           Factor            Ratio               Cycles/Pel        Mhz Required
                176                 144                30                60                 10.3                53.89                41
                176                 144                30                40                 13.1                49.08                37
                640                 480                30                60                 14.0                43.68                403
                640                 480                30                40                 19.2                 38.7                357

               *For more details and other benchmarks look into the documentation (Developer Guides) that comes with the software product brief for
                 JPEG/MJPEG SDK



! Allocate                the output streambuffer
     "   StreamBuffer_Obj = JPEG_MemAlloc_NEW(3 * Input_Width *
         Input_Height,1,MEM_TYPE_DATA);
         !   Typical application would streaming output to local file system (i.e. fprintf) or remote
             host file system.
! Instantiate                  JPEG Encoder
     "   lJpegEnc = JPEG_Encoder_NEW(&lImageParam);


29
Encode Video
 ! Step      1: Wait for full YCrCb 4:2:0 Buffer

 ! Step      2: Pass YCrCb 4:2:0 Buffer Pointer
     "   JPEG_McuBuffer_CONFIG(mcu_ex, MCU_POINTER_C1, (unsigned int)lInputBuffer);

 ! Step      3: Perform MJPEG Encode
     "   JPEG_EncodeSequentialImage(lJpegEnc, &NumBytes);

 ! To     encode next frame, go to Step 1
                  Video_Frames[0]                                                     Compressed Video
                                                                                      (contains multiple
                         Blanking                                                       frames of data)
                          Field 1      Me
                        Active Video     mo
                         Blanking          ryD
                          Field 2
                                              MA
                        Active Video               Y/C             Y
                         Blanking
                                                      r/C
                                                         b
                                                                            MJPEG
                  Video_Frames[1]                                           Encoder
                                                          b
                         Blanking
                                                       r/C    Cr       Cb
                          Field 1
                                                  A Y/C
                        Active Video
                                              M
                         Blanking          ryD                YCrCb 4:2:0
                                         mo                     Buffer
                                       Me
                          Field 2
                        Active Video
                         Blanking

                4:2:2 Video Frames
                     in SDRAM



 ! Without   Double Buffering, frame being encoded is also being
     overwritten with new data – result is corrupted image

30
Encode YCrCb 4:2:0 Frame with Double
Buffering
! To      encode multiple frames, double buffering is used
     " Ensures previous frame which is being encoded isn’t corrupted
      with next frame data


                                   ADSP-BF561                Video_Frames[0]                                                                       Compressed Video
                                                                   Blanking
                                                                                                           Y                                       (contains multiple
                                                                    Field 1
                                                                                                                    En                               frames of data)
                                                                  Active Video                                        co
                                                                                 Memory DMA Y/Cr/Cb                      de
                                                      E0
                                                                   Blanking
                                                                                                                            F   ram
                                                 AM                 Field 2
                                                                                                      Cr       Cb
                                              FR                  Active Video                                                     e0
                                          L                                                                                              MJPEG
                                      FIL                          Blanking
                            PPI0




                 ADV7183B
                   ADC               FIL                    Video_Frames[1]                                                              Encoder
                                           LF                                                                                       e1
 Video Source                                RA
                                                                   Blanking
                                                                                                                                 ram
                                               ME                   Field 1                                                 eF
                                                                  Active Video                             Y              od
                                                      1                                                             E   nc
                                                                   Blanking      Memory DMA Y/Cr/Cb
                                                                    Field 2
                                                                  Active Video
                                                                   Blanking
                                                                                                      Cr       Cb
                                                           Video Frames in SDRAM




31
Outline for USB Sub-module

! Blackfin   USB-LAN EZ-Extender

! Simple   Blackfin-Host Data Transfers over USB 2.0




32
Blackfin USB-LAN EZ-Extender Hardware

! Adds       USB 2.0 High speed connectivity to Blackfin
     " PLX   NET2272 USB 2.0 High Speed Controller
! USB-LAN    EZ-Extender plugs on to ADSP-BF533,
     ADSP-BF537, and ADSP-BF561 EZ-KITs




33
Blackfin USB-LAN EZ-Extender Benchmarks

               Processor          OUT -> from            IN <- to host
                                host MBytes/sec           MBytes/sec
                  BF533                 20.0                   25.1

                  BF537                 20.3                   25.0

                  BF561                 16.3                   20.0



     !   Test Conditions
         "   Using the provided host application, bulk host driver, and firmware

         "   Test system: P4 2.0 GHz, 768 MB RAM, USB 2.0 host controller,
             WinXP Pro SP2, no other USB devices on the bus

         "   Measure on Windows and takes into account complete transaction
             time from host application point of view


34
Simple Blackfin-Host Transfers Via
NET2272 USB
! Receive    USB command block from the Host indicating what
     function for Blackfin to perform

! Perform       IO Based on Command using File I/O or Stdio
     " UploadData payload to Host PC
     " Download Data payload from Host PC



                                   ADSP-BF561

                                                       USB Commands



                                                                     USB
                                                EBIU




                                                                    NET2272

                         Payload
                                                       Move Data Payload
                          Memory




35
Basic Commands Overview

! Application     exchanges command blocks with the host
     " Indicating what functions to perform
     " Refer to USBCMD.h for default USBCB command block structure


Example:
              typedef struct _USBCB   // USB command block
              {
                ULONG ulCommand;      // command to execute
                ULONG ulData;         // generic data field OR 1st Parameter
                ULONG ulCount;        // number of bytes to transfer OR 2nd Parameter
                ULONG ulPar3;         // 3rd Parameter
                ULONG ulPar4;         // 4th Parameter
              } USBCB, *PUSBCB;




36
Basic Commands Usage

! USBCMD.h                 also contains default Commands
                       enum _USB_COMMAND
                       {
                          NO_COMMAND,                 // nothing to do here...
                          GET_FW_VERSION,             // get the firmware version
                          QUERY_SUPPORT,              // query for support
                          QUERY_REPLY,                // query reply
                          LOOPBACK,                   // run loopback on the device
                          MEMORY_READ,                // read from specified memory on the device
                          MEMORY_WRITE,               // write to specified memory on the device
                          USBIO_START,                // run USB IO on this device
                          USBIO_STOP,                 // stop USB IO on this device
                          USBIO_OPEN,                 // open file on host
                          …
                       };


! Once     Command has been received, switch on the command
     received
     "   switch( pusbcb->ulCommand )
         Example:
     switch( pusbcb->ulCommand )
      {
         case USBIO_START:         PerformIo( USB_DevHandle );   break;                                         // perform IO over USB
         case MEMORY_READ:         ReadMemory( USB_DevHandle, (u8*)pusbcb->ulData, pusbcb->ulCount ); break;    // read memory
         case MEMORY_WRITE:        WriteMemory( USB_DevHandle, (u8*)pusbcb->ulData, pusbcb->ulCount ); break;   // write memory
         default:                  exit(1);       break;                                                        // unsupported command
       }



37
Additional Inforamation on Blackfin USB

! Hardware      schematics and layout data available on ftp site
     " ftp://ftp.analog.com/pub/tools/Hardware


! Blackfin     USB firmware
     " Ships with latest VisualDSP++
     " C language examples - loopback and IO redirection
     " C language NET2272 driver – bulk and isochronous versions


! Windows      host application
     " Shipswith latest VisualDSP++
     " C/C++ example built with Microsoft Visual Studio .NET




38
Rapid Development of a MJPEG
             Video Encoder




39
Rapid Development with Common
Components
! Video-In
! Video-Out
! MJPEG Encoder
! USB Host                         ADSP-BF561                    Video_Frames[0]
                                                                       Blanking
                                                                        Field 1
                                                                      Active Video     Di
                                                                                         sp
                                                                       Blanking            lay
                                          E0                                                     FR
                                       AM
                                                                        Field 2
                                                                                                   AM
                                    FR
                                                                      Active Video
                                  L                                    Blanking
                                                                                                      E    0
                                FIL
                        PPI0




                                                                                                                PPI1
             ADV7183B                                                                                                          ADV7179
              Decoder                                           Video_Frames[1]
                               FIL                                                                                             Encoder
                                   LF                                  Blanking                             1
                                     RA                                 Field 1                          ME
                                       ME                             Active Video
                                                                                                   F   RA
                                            1                                                  y
                                                                                           pla
                                                                       Blanking
                                                                        Field 2
                                                                      Active Video
                                                                                       Dis
                                                                       Blanking


                                                              Video Frames in SDRAM


                                                                                      Compressed Video
                                                                                      (contains multiple
                                                                                        frames of data)
                                                     Y

                                                                                                                         USB Commands
                                                Cr       Cb
                                                                            MJPEG
                                                                                                                                    USB




                                                                                                                  EBIU
                                                     Y
                                                                            Encoder                                                NET2272
                                                                                             Memory
                                                Cr       Cb
                                                                                                                         Move Data Payload




40
Software Flow                                             Setup MJPEG
                                                         Parameters and
                                                         OPEN remote file
                                                       (‘MJPEG_Encode.c’)
                                                                                       ADV71783B
          Setup System                                                                Device Driver
        Services (‘main.c’)                            Setup Video Devices
                                                                                        ADV7179
                                                     ADV7183B and ADV7179
                                                                                      Device Driver
                                                       (‘MJPEG_Encode.c’)
                                       NET2272
                                     Device Driver
         Setup NET2272
         Device (‘main.c’)                                 Press SW6 on
                                                                              NO
                                                         EZ-KIT to START?          SW6 is arbitrary. For example, could
                                                        (‘MJPEG_Encode.c’)         be motion activated sensors which
                                                                                       kicks off MJPEG encoding


                                                                   YES

            New USB             NO
            command?
                                                      MJPEG Encode Video
            (‘main.c’)                                                                           MJPEG
                                                     Frames as they become
                                                                                                LIBRARY
                                                            available
                   YES                                 (‘MJPEG_Encode.c’)


         Identify MJPEG
      Coding_Algorithm and                                Perform IO of
     Coding_Action (‘main.c’)                           compressed MJPEG
                                                       image data over USB
                                                       (‘MJPEG_Encode.c’)


      Perform MJPEG action
     and send Encoded image
            over USB                                         Press SW6 on     NO
                                                           EZ-KIT to STOP?
            (‘main.c’)                                   (‘MJPEG_Encode.c’)


                                                                   YES




                                                       CLOSE remote file
41                                                    (‘MJPEG_Encode.c’)
What’s Required
! Hardware
     " ADSP-BF561EZ-Kit (Silicon Revision 0.3 or higher)
     " ADSP-USB_EZ_LAN Extender Card
     " PC
         ! Running WinXP
         ! Native USB2.0 port is best
                 − If you do not have, use a PCMCIA plug-in card. Transfer rate will degrade by ~30%
     " DVD player (NTSC) for input
     " Display (NTSC) for output
! Toolset
     " VisualDSP++             4.0 with December 2005 update and Emulator
             "   If you don’t want to recompile, use the provided *.dxe executable or burn the
                 provided *.ldr image into flash memory
! Software
     " ZIP        file
             "   Posted with this presentation


42
Installation [1/4]
! Copy      or extract the Software into a directory on your hard-
     disk (let’s call it “ROOT” directory)

! Connect     Extender Card onto ADSP-BF561 EZ-kit

! Connect  USB2.0 port on PC to USB2.0 port ON THE
     EXTENDER CARD

! Set    DIP switches according to table on next Slide




43
Installation [2/4]
                                  Setting for this demo
     EZkit DIP switches
                 SW3                      All off except #6
                 SW9                   All off except #1 and #6
                 SW2                           All off
                 SW1                           All off
     Extender card DIP switches
                 SW1                      All on except #4
                 SW2                      All on except #1




44
Hardware System Overview (MJPEG
Encoder)

                                                                                 Simple Video Pass Through

                                  ADV7183B                        ADV7179




                                                                            ADSP-BF561 EZ-KIT
                                                  BF561
                                              (MJPEG Encoder)




                                                   USB
                                                 NET2272

                                         EZ-USB EXTENDER



                                                           USB 2.0 to Host PC
                                                           - Compressed Video flows from Blackfin to
     Stack EZ-USB Extender onto                            Host PC
     ADSP-BF561 EZ-KIT
                                                                 -*.AVI files get stored to local hard drive




45
Installation [3/4]
! Connect   the NTSC display to the “Video Out” Connector J6
     on ADSP-BF561 EZ-Kit

! Connect   the NTSC DVD player to the “Video In” Connector J6
     on ADSP-BF561 EZ-Kit

! Power    DVD Player and Display

                                          J6 on ADSP-
                                          BF561 EZ-Kit




46
Installation [4/4]
! Power  the EZ-Kit
! Start VisualDSP++
! Load the Image File into flash memory
     " Use VisualDSP’s “flash programming tool”
     " Image file is “ROOTcodec_blkfnjmjpeg_appBF561bin

! Exit     VisualDSP++ and reset the EZ-kit

! Windows          should now detect a new USB Device
     " Follow   the prompts to install the device driver
       "   Specify the path to the device driver
     " DeviceDriver is located in “ROOTcodec_hosthostdriver”
      directory
       " This step needs to be done only once
       " Windows will remember device driver next time




47
USAGE [1/3] – General
! Open        a DOS prompt Terminal on your PC
       !   Generally under Start->All Programs->Accessories
! Change         Directory to “ROOTcodec_hosthostapp” directory
       !   With DOS’s “cd” command (if necessary, switch to the hard-disk drive
           by typing “C:”)

! The   “hostapp.exe” application is the main control for the
     Demo Application that is running on the DSP.

!A     few tests:
       ! Type “hostapp –h” and press “enter” - what happens?
       ! Type “hostapp –a” - will tell you if and how many DSPs are connected

       ! Type “hostapp –v” - more information about the application



! If   the “hostapp” detects a device, you are ready to proceed!


48
USAGE [2/3] - General

     A few general explanations:
     " Open    an Explorer Window at
       "   “ROOTimages”
           − Call this the “work directory”
       "   “ROOTimagesMJPEG”
           − Target directory where encoded MJPEG *.AVI files will be stored


     The application uses File I/O to upload Payload to the
     Host PC
     " DISPLAYs   information about the encoding/decoding process
     " Follow instructions on the terminal CAREFULLY
       " DO NOT TYPE in the terminal unless instructed to
       " Accidentally press a key at the wrong time will abort the program. Just
         press the reset button on the EZ-kit


49
USAGE [3/3] – MJPEG ENCODER
!    Open the specification file in the work directory
         !   mjpeg_encoder_spec.txt

!    Each line specifies a target MJPEG (*.avi) file to be encoded from a Video source
         !   Type the name: for instance mymovie
         !   Type the size (Horizontal Vertical): for instance 320 240
         !   Type the encoding quality factor (0 [least] – 100 [max])

!    Repeat for as many recordings/files you like to take
         Example:       DISPLAY_MPEG_TEST1 352 288 60
                        DISPLAY_MPEG_TEST3 640 480 70

!    Save the file

!    Run ENCODER from the Host PC terminal:
         !   Type “hostapp –m e”            - Sets the DSP application to (m)jpeg (e)ncoding
         !   Type “hostapp –u”              - Starts encoder application
     "   NOW (as instructed) press button on the EZ-kit
         !   Press to start recording
         !   Press to stop recording
         !   Press ENTER on the keyboard to move to the next file
         !   Repeat for each file you specified in the steps above

!    Play the files !
     "   Find files specified above in MJPEG directory in the work directory
     "   Play the files by double-clicking on them

50
Additional Information

! Blackfin     USB firmware
     " Ships with latest VisualDSP++
     " C language examples - loopback and IO redirection
     " C language NET2272 driver – bulk and isochronous versions


! Windows      host application
     " Shipswith latest VisualDSP++
     " C/C++ example built with Microsoft Visual Studio .NET


! For   questions, click “Ask A Question” button or
     send an email to Processor.support@analog.com




51

More Related Content

What's hot

Polycom Video Communications
Polycom Video CommunicationsPolycom Video Communications
Polycom Video Communications
Videoguy
 
Datavideo MS-900
Datavideo MS-900Datavideo MS-900
Datavideo MS-900
AVNed
 
Phabrix Sx
Phabrix SxPhabrix Sx
Phabrix Sx
ssennett
 
Qvpro datasheet
Qvpro datasheetQvpro datasheet
Qvpro datasheet
ciperi
 
Datavideo SE-600
Datavideo SE-600Datavideo SE-600
Datavideo SE-600
AV ProfShop
 
Qvsd datasheet
Qvsd datasheetQvsd datasheet
Qvsd datasheet
ciperi
 
FPGA Camp - Softjin Presentation
FPGA Camp - Softjin PresentationFPGA Camp - Softjin Presentation
FPGA Camp - Softjin Presentation
FPGA Central
 

What's hot (19)

Polycom Video Communications
Polycom Video CommunicationsPolycom Video Communications
Polycom Video Communications
 
Blonder Tongue HDE-2H-QAM Presentation
Blonder Tongue HDE-2H-QAM PresentationBlonder Tongue HDE-2H-QAM Presentation
Blonder Tongue HDE-2H-QAM Presentation
 
Datavideo MS-900
Datavideo MS-900Datavideo MS-900
Datavideo MS-900
 
ICE Presentation: Integrated Component Characterization Environment
ICE Presentation: Integrated Component Characterization EnvironmentICE Presentation: Integrated Component Characterization Environment
ICE Presentation: Integrated Component Characterization Environment
 
M2sat Regional News Gathering system ppt 191112
M2sat Regional News Gathering system ppt 191112 M2sat Regional News Gathering system ppt 191112
M2sat Regional News Gathering system ppt 191112
 
Phabrix Sx
Phabrix SxPhabrix Sx
Phabrix Sx
 
X Point Vcon
X Point VconX Point Vcon
X Point Vcon
 
JVC SR-HD1500
JVC SR-HD1500JVC SR-HD1500
JVC SR-HD1500
 
Hd 600 Datasheet
Hd 600 DatasheetHd 600 Datasheet
Hd 600 Datasheet
 
Robust Embedded Applications OSGi ME Platforms
Robust Embedded Applications OSGi ME PlatformsRobust Embedded Applications OSGi ME Platforms
Robust Embedded Applications OSGi ME Platforms
 
SONY IBC2008
SONY IBC2008SONY IBC2008
SONY IBC2008
 
Qvpro datasheet
Qvpro datasheetQvpro datasheet
Qvpro datasheet
 
Datavideo SE-600
Datavideo SE-600Datavideo SE-600
Datavideo SE-600
 
Introduction of AMD Virtual Interrupt Controller
Introduction of AMD Virtual Interrupt ControllerIntroduction of AMD Virtual Interrupt Controller
Introduction of AMD Virtual Interrupt Controller
 
Qvsd datasheet
Qvsd datasheetQvsd datasheet
Qvsd datasheet
 
FPGA Camp - Softjin Presentation
FPGA Camp - Softjin PresentationFPGA Camp - Softjin Presentation
FPGA Camp - Softjin Presentation
 
Core Stor Ip Recording V1
Core Stor Ip Recording V1Core Stor Ip Recording V1
Core Stor Ip Recording V1
 
Digigram Aqilim Fit
Digigram Aqilim FitDigigram Aqilim Fit
Digigram Aqilim Fit
 
AJA Kipro Mini
AJA Kipro MiniAJA Kipro Mini
AJA Kipro Mini
 

Viewers also liked (6)

histoGraph presented to MMSP 2013
histoGraph presented to MMSP 2013histoGraph presented to MMSP 2013
histoGraph presented to MMSP 2013
 
Microchip's 16-bit and 32-bit PIC MCUs
Microchip's 16-bit and 32-bit PIC MCUsMicrochip's 16-bit and 32-bit PIC MCUs
Microchip's 16-bit and 32-bit PIC MCUs
 
H8S Microcontroller Family Overview
H8S Microcontroller Family OverviewH8S Microcontroller Family Overview
H8S Microcontroller Family Overview
 
DSPIC33F: High Performance 16-bit Digital Signal Controllers
DSPIC33F: High Performance 16-bit Digital Signal ControllersDSPIC33F: High Performance 16-bit Digital Signal Controllers
DSPIC33F: High Performance 16-bit Digital Signal Controllers
 
Being a business assistant with element14 in krakow
Being a business assistant with element14 in krakowBeing a business assistant with element14 in krakow
Being a business assistant with element14 in krakow
 
Optical Encoders
Optical EncodersOptical Encoders
Optical Encoders
 

Similar to Rapid development Using Blackfin

TEDxBaltimore 2013 - Multimedia Guide
TEDxBaltimore 2013 - Multimedia GuideTEDxBaltimore 2013 - Multimedia Guide
TEDxBaltimore 2013 - Multimedia Guide
TEDxBaltimore
 
Flash Iphone Fitc 2010
Flash Iphone Fitc 2010Flash Iphone Fitc 2010
Flash Iphone Fitc 2010
Yagiz Gurgul
 
AU_NVR_V4.60.005 build220927_Release Notes.pdf
AU_NVR_V4.60.005 build220927_Release Notes.pdfAU_NVR_V4.60.005 build220927_Release Notes.pdf
AU_NVR_V4.60.005 build220927_Release Notes.pdf
SunnyLai23
 
05 foundation for rom user perspective 11 19-11
05 foundation for rom user perspective 11 19-1105 foundation for rom user perspective 11 19-11
05 foundation for rom user perspective 11 19-11
FieldComm Group
 

Similar to Rapid development Using Blackfin (8)

LDI 2012 System Integration
LDI 2012 System IntegrationLDI 2012 System Integration
LDI 2012 System Integration
 
TEDxBaltimore 2013 - Multimedia Guide
TEDxBaltimore 2013 - Multimedia GuideTEDxBaltimore 2013 - Multimedia Guide
TEDxBaltimore 2013 - Multimedia Guide
 
Specsheet sncdh160
Specsheet sncdh160Specsheet sncdh160
Specsheet sncdh160
 
Flash Iphone Fitc 2010
Flash Iphone Fitc 2010Flash Iphone Fitc 2010
Flash Iphone Fitc 2010
 
AU_NVR_V4.60.005 build220927_Release Notes.pdf
AU_NVR_V4.60.005 build220927_Release Notes.pdfAU_NVR_V4.60.005 build220927_Release Notes.pdf
AU_NVR_V4.60.005 build220927_Release Notes.pdf
 
05 foundation for rom user perspective 11 19-11
05 foundation for rom user perspective 11 19-1105 foundation for rom user perspective 11 19-11
05 foundation for rom user perspective 11 19-11
 
Junliang`s Resume
Junliang`s ResumeJunliang`s Resume
Junliang`s Resume
 
WalB: Real-time and Incremental Backup System for Block Devices
WalB: Real-time and Incremental Backup System for Block DevicesWalB: Real-time and Incremental Backup System for Block Devices
WalB: Real-time and Incremental Backup System for Block Devices
 

More from Pantech ProLabs India Pvt Ltd

More from Pantech ProLabs India Pvt Ltd (20)

Registration process
Registration processRegistration process
Registration process
 
Choosing the right processor for embedded system design
Choosing the right processor for embedded system designChoosing the right processor for embedded system design
Choosing the right processor for embedded system design
 
Brain Computer Interface
Brain Computer InterfaceBrain Computer Interface
Brain Computer Interface
 
Electric Vehicle Design using Matlab
Electric Vehicle Design using MatlabElectric Vehicle Design using Matlab
Electric Vehicle Design using Matlab
 
Image processing application
Image processing applicationImage processing application
Image processing application
 
Internet of Things using Raspberry Pi
Internet of Things using Raspberry PiInternet of Things using Raspberry Pi
Internet of Things using Raspberry Pi
 
Internet of Things Using Arduino
Internet of Things Using ArduinoInternet of Things Using Arduino
Internet of Things Using Arduino
 
Brain controlled robot
Brain controlled robotBrain controlled robot
Brain controlled robot
 
Brain Computer Interface-Webinar
Brain Computer Interface-WebinarBrain Computer Interface-Webinar
Brain Computer Interface-Webinar
 
Development of Deep Learning Architecture
Development of Deep Learning ArchitectureDevelopment of Deep Learning Architecture
Development of Deep Learning Architecture
 
Future of AI
Future of AIFuture of AI
Future of AI
 
Gate driver design and inductance fabrication
Gate driver design and inductance fabricationGate driver design and inductance fabrication
Gate driver design and inductance fabrication
 
Brainsense -Brain computer Interface
Brainsense -Brain computer InterfaceBrainsense -Brain computer Interface
Brainsense -Brain computer Interface
 
Median filter Implementation using TMS320C6745
Median filter Implementation using TMS320C6745Median filter Implementation using TMS320C6745
Median filter Implementation using TMS320C6745
 
Introduction to Code Composer Studio 4
Introduction to Code Composer Studio 4Introduction to Code Composer Studio 4
Introduction to Code Composer Studio 4
 
Waveform Generation Using TMS320C6745 DSP
Waveform Generation Using TMS320C6745 DSPWaveform Generation Using TMS320C6745 DSP
Waveform Generation Using TMS320C6745 DSP
 
Interfacing UART with tms320C6745
Interfacing UART with tms320C6745Interfacing UART with tms320C6745
Interfacing UART with tms320C6745
 
Switch & LED using TMS320C6745 DSP
Switch & LED using TMS320C6745 DSPSwitch & LED using TMS320C6745 DSP
Switch & LED using TMS320C6745 DSP
 
Led blinking using TMS320C6745
Led blinking using TMS320C6745Led blinking using TMS320C6745
Led blinking using TMS320C6745
 
Introduction to tms320c6745 dsp
Introduction to tms320c6745 dspIntroduction to tms320c6745 dsp
Introduction to tms320c6745 dsp
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Recently uploaded (20)

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

Rapid development Using Blackfin

  • 1. The World Leader in High Performance Signal Processing Solutions Rapid Development of a Blackfin-based Video Application Presented By: Glen Ouellette
  • 2. About this Module This module discusses the rapid development process of a Blackfin® Video application using readily available and fully supported software and hardware modules. It is recommended that users have some understanding of: ! Basic knowledge of software terminology ! Experience in embedded systems ! Blackfin System Services and Device Drivers 2
  • 3. Module Outline ! Video-In " Refresher on Device Driver " Video Capture using ADV7183B Video Decoder ! Video-Out " Video Display using ADV7179 Video Encoder ! Video Compression " Overview of MJPEG offering " Encoding Video Data ! USB " Blackfin USB-LAN EZ-Extender " Blackfin-Host data transfer over USB 2.0 ! Rapid Develeopment of a MJPEG Encode 3
  • 4. Outline of Video-In Sub-module !A short Device Driver refresher ! Simple Video Capture using ADV7183B Video Decoder 4
  • 5. Device Driver Refresher ! Standardized API " User interface is the same across all device drivers ! Independent of driver " Allows buffers to be passed from driver to driver ! Independent of processor " Does not require change when moving from BF561 to BF537 ! DeviceDrivers are Totally Independent ! User Application provides buffers to device driver " Provided to driver via adi_dev_Read() or adi_dev_Write() ! Inbound buffers – Filled with data received from the device ! Outbound buffers – Contain data to send out through the device 5
  • 6. Device Driver Refresher (continued) ! Application involvement " Initialize services ! Independent Device drivers manage their own set of system services " Drivers call into system services as required ! Video In Device Driver (e.g. ADV7183B) " Calls into DMA Manager " Calls into Interrupt Manager Application " Calls into Timer Control Video In Video Out " Calls into DCB Device Driver Device Driver USB Device Driver System Services 6
  • 7. Additional Information on Device Drivers ! Device Drivers and System Services Manual for Blackfin Processors − http://www.analog.com/processors/manuals ! Device Drivers and System Services Addendum (Sept 2005) − ftp://ftp.analog.com/pub/tools/patches/Blackfin/VDSP++4.0/ 7
  • 8. Video-In Data Flows ! Video Decoder is configured to accept source input " NTSC or PAL " Example: ADV7183B with NTSC input ! Hardware " ADSP-BF561 EZ-Kit (Silicon Revision 0.3 or higher) ! Has onboard ADV7183B Video Decoder ! ADV7183B Device Driver provided with VisualDSP++ " Others ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video PPI0 ADV7183B FILL FRAME 0 Blanking Process Decoder Field 2 Video Source Active Video Blanking Video Frame Stored in SDRAM 8
  • 9. Double Buffering ! Double Buffering is typical in Video Applications " Benefit ! Pass data into a single frame while processing/displaying data elements of a previously filled frame ! Avoids over writing unprocessed pixels/frames " Often Multiple Buffering (6 or more) ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video Blanking E0 Process R AM Field 2 LF Active Video FIL Blanking PPI0 ADV7183B Video_Frames[1] FIL Decoder LF RA Blanking Video Source ME Field 1 1 Active Video Blanking Process Field 2 Active Video Blanking 9
  • 10. Dataflow Method: Chaining with Loopback ! Chaining with Loopback " Device driver automatically loops back to the first buffer after the last buffer in the chain is processed " Application doesn’t need to resupply buffers ! Lower overhead ! Device driver never “starves” for data ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video 0 Blanking ME F RA Field 2 L Active Video FIL Blanking PPI0 ADV7183B Video_Frames[1] Decoder FIL Blanking Video_Frames[0] Video_Frames[1] LF RA Field 1 ME Active Video 1 Blanking Field 2 Active Video Blanking 10
  • 11. Video-In Programming Sequence ! Initialize System Services ! Good practice to reset Video Decoder " OnBlackfin EZ-Kits, ADV7183B Reset is controlled via Programmable Flag ! Open ADV7183B Device Driver " ‘AD7183DriverHandle’ " Configure for Inbound traffic from ADV7183B to Video Buffer " PPI_Callback_In ezErrorCheck(adi_dev_Open(DeviceManagerHandle, &ADIAD7183EntryPoint, // pdd entry point 0, // device instance NULL, // client handle callback identifier &AD7183DriverHandle, // DevMgr handle for this device ADI_DEV_DIRECTION_INBOUND,// data direction for this device DMAManagerHandle, // handle to DmaMgr for this device DCBManagerHandle, // handle to deferred callback service PPI_Callback_In)); // deferred callback /********* open AD7183 via PPI0 ****************************************/ ezErrorCheck(adi_dev_Control(AD7183DriverHandle, ADI_AD7183_CMD_OPEN_PPI, (void *)0)); 11
  • 12. Video-In Programming Sequence (cont’d) /******** ADV7183 Inbound Buffers******************/ In1_Buffer2D.Data = Video_Frames[0]; In1_Buffer2D.ElementWidth = sizeof(u16); In1_Buffer2D.XCount = (1716/2); ! Allocate two 2D_Buffers In1_Buffer2D.XModify = 2; In1_Buffer2D.YCount = 525; In1_Buffer2D.YModify = 2; " In1_Buffer2D, In2_Buffer2D In1_Buffer2D.CallbackParameter = 1; In1_Buffer2D.pNext = &In2_Buffer2D; ! Pointer to the data In2_Buffer2D.Data = Video_Frames[1]; " Video_Frames[0] and Video_Frames[1] In2_Buffer2D.ElementWidth = sizeof(u16); In2_Buffer2D.XCount = (1716/2); ! Element width In2_Buffer2D.XModify = 2; In2_Buffer2D.YCount = 525; " 16-bit wide element In2_Buffer2D.YModify = 2; In2_Buffer2D.CallbackParameter = 2; In2_Buffer2D.pNext = NULL; ! XCount, XModify, YCount, YModify " ITU-R BT656 NTSC Video Frame ! Callback parameter " For this example, ‘1’ indicates Video_Frames[0] and ‘2’ indicates Video_Frame[1] ! pNext " Pointer to the next Video_Frame buffer in the chain (NULL if the last Video_Frame buffer in chain) 12
  • 13. Then Enable Dataflow Sequence ! Start Capturing Video Data from PPI0 into Video_Frames[0] and Video_Frame[1] " adi_dev_Control(AD7183DriverHandle, ADI_DEV_CMD_SET_DATAFLOW, (void*)TRUE)); ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video 0 Blanking ME RA Field 2 LF Active Video FIL PPI0 ADV7183B Blanking Decoder FIL LF Video_Frames[1] RA Blanking ME 1 Field 1 Active Video Blanking Field 2 Active Video Blanking 13
  • 14. Programming Sequence for ADV7183B Open ADV7183 driver for Inbound dataflow Configure ADV7183 driver for chained loopback, ITU-R BT656 mode etc. ADV7183B Driver Provide 2 frame buffers for driver to fill Application Enable dataflow Driver makes callback when frame buffer is filled Callback function provides next buffer for driver to fill 14
  • 15. Outline for Video-Out Sub-module ! Simple Video Display using ADV7179 Video Encoder 15
  • 16. Video-Out Data Flows ! Video Encoder is configured to drive display " NTSC or PAL " Example: ADV7179 connected to NTSC TV ! Hardware " ADSP-BF561 EZ-Kit (Silicon Revision 0.3 or higher) ! Has onboard ADV7179 Video Encoder ! ADV7179 Device Driver provided with VisualDSP++ ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video PPI1 Processed Blanking Display FRAME 0 ADV7179 Field 2 Active Video Encoder Blanking Video Frame Stored in SDRAM 16
  • 17. Double Buffering ! Double Buffering is typical in Video Applications ! Benefits ! Display a single frame while filling data elements of a previously displayed filled frame ! Avoids over displaying old pixels/frames ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video Di sp Blanking lay Processed FR Field 2 AM Active Video E Blanking 0 ADV7179 PPI1 Video_Frames[1] Blanking Encoder 1 Field 1 ME Active Video RA yF Processed Blanking ispla Field 2 D Active Video Blanking 17
  • 18. Dataflow Method: Chaining with Loopback ! Chaining with Loopback " Device driver automatically loops back to the first buffer after the last buffer in the chain is processed ! Application does not need to re-supply buffers " Lower overhead " Device driver never “starves” for data ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video Di sp Blanking lay FR Field 2 Active Video AM E 0 Video_Frame[0] Video_Frame[1] Blanking ADV7179 PPI1 Video_Frames[1] Encoder Blanking 1 Field 1 ME Active Video RA yF Blanking pla Field 2 Dis Active Video Blanking 18
  • 19. Video-Out Programming Sequence ! Initialize System Services ! Good practice to reset Video Encoder " OnBlackfin EZ-Kits, ADV7179 Reset is controlled via Programmable Flag ! Open ADV7179 Device Driver " ‘AD7179DriverHandle’ " Configure for Outbound traffic from Video Buffer to ADV7179 " PPI_Callback_Out ezErrorCheck(adi_dev_Open( DeviceManagerHandle, &ADIADV717xEntryPoint, // Device Entry point 0, // Device number NULL, // No client handle &AD7179DriverHandle, // Device manager handle address ADI_DEV_DIRECTION_OUTBOUND, // Data Direction DMAManagerHandle, // Handle to DMA Manager DCBManagerHandle, // Handle to callback manager PPI_Callback_Out)); // deferred callback /********* open AD7179 via PPI1 **************************************** ezErrorCheck(adi_dev_Control( AD7179DriverHandle, ADI_ADV717x_CMD_SET_PPI_DEVICE_NUMBER, (void*)1 )); 19
  • 20. Video-Out Programming Sequence – Cont’d /******** AD7179 Outbound Buffers*******************/ Out1_Buffer2D.Data = Video_Frames[0]; Out1_Buffer2D.ElementWidth = sizeof(u16); Out1_Buffer2D.XCount = (1716/2); Out1_Buffer2D.XModify = 2; ! Allocate two 2D_Buffers Out1_Buffer2D.YCount = 525; Out1_Buffer2D.YModify = 2; " Out1_Buffer2D, Out2_Buffer2D Out1_Buffer2D.CallbackParameter = 1; Out1_Buffer2D.pNext = &Out2_Buffer2D; ! Pointer to the data Out2_Buffer2D.Data = Video_Frames[1]; Out2_Buffer2D.ElementWidth = sizeof(u16); " Video_Frames[0] and Video_Frames[1] Out2_Buffer2D.XCount = (1716/2); Out2_Buffer2D.XModify = 2; ! Element width Out2_Buffer2D.YCount = 525; Out2_Buffer2D.YModify = 2; Out2_Buffer2D.CallbackParameter = 2; " 16-bit wide element Out2_Buffer2D.pNext = NULL; ! XCount, XModify, YCount, YModify " ITU-R BT656 NTSC Video Frame = 1716 Bytes per line by 525 lines per Frame ! Callback parameter " For this example, ‘1’ indicates Video_Frame[0] and ‘2’ indicates Video_Frame[1] ! pNext " Pointer to the next Video_Frame buffer in the chain (NULL if the last Video_Frame buffer in chain) 20
  • 21. Then Enable Dataflow Sequence ! Start Displaying Video Data from Video_Frames[0] and Video_Frames[1] into PPI1 " adi_dev_Control(AD7179DriverHandle, ADI_DEV_CMD_SET_DATAFLOW, (void*)TRUE)); ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video Di sp Blanking lay Field 2 FR Active Video AM E 0 Blanking ADV7179 PPI1 Video_Frames[1] Encoder Blanking 1 Field 1 ME Active Video F RA lay sp Blanking Field 2 Di Active Video Blanking 21
  • 22. Programming Sequence for ADV7179 Open ADV7179 driver for Outbound dataflow Configure ADV7179 driver for chained loopback, ITU-R BT656 mode etc. ADV7179 Driver Provide 2 frame buffers for driver to send out Application Enable dataflow Driver makes callback when frame buffer has been sent out Callback function provides next buffer for driver to send out 22
  • 23. Recap: Video-In and Video-Out ! Installed ADV7183B Device Driver " Video Decoder is configured to accept source input ! Installed ADV7179 Device Driver " Video Encoder is configured to drive display ! Independent Drivers, but can share Video Frame Buffers ADSP-BF561 Video_Frames[0] Video_Frames[0] ADSP-BF561 Blanking Blanking Field 1 Field 1 Active Video Active Video Di sp lay E0 Blanking Blanking FR AM Field 2 Field 2 Video Source AM FR Active Video Active Video L E 0 FIL Blanking Blanking PPI0 ADV7183B PPI1 Decoder Video_Frames[1] Video_Frames[1] ADV7179 FIL LF Blanking Blanking 1 Encoder RA Field 1 Field 1 ME ME Active Video Active Video F RA 1 y Blanking Blanking pla Field 2 Active Video Field 2 Dis Active Video Blanking Blanking 23
  • 24. Recap: Rapid Development of Video Pass Through ! Reuse Video Frame buffers to create Simple Video Pass Through " Only 1 Frame Delay between input and output ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video Di sp lay E0 Blanking M Field 2 FR RA Active Video AM LF E 0 FIL Blanking PPI0 PPI1 ADV7183B ADV7179 Decoder Video_Frames[1] FIL Encoder LF E1 Blanking RA Field 1 AM ME Active Video FR 1 y Blanking pla Field 2 Dis Active Video Blanking Video Frames in SDRAM Quick Tips: " Map video frames into different banks of SDRAM to avoid latencies " Configure DMA traffic control to optimize unidirectional traffic and reduce SDRAM bus turnaround penalties 24
  • 25. Recap: Beyond Pass Through - Video Processing ! Simple Video Pass Through is common " E.g. Back-up Video Camera, Side-view Mirrors, Back seat monitor ! Often, Inbound Frames are processed/compressed by software codecs " E.g. Sobel Edge detection, MJPEG Encoding, MPEG Encoding ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video Di sp 0 Blanking lay ME Field 2 FR RA Active Video AM LF E 0 FIL Blanking PPI0 PPI1 ADV7183B ADV7179 Decoder Video_Frames[1] FIL Encoder L Blanking 1 FR AM ME RA Field 1 E Active Video y F 1 Blanking pla Field 2 Dis Active Video Blanking Video Frames in SDRAM Compressed Video MJPEG Encoder Memory 25
  • 26. Outline for Encoding Video Data Sub- module ! Overview of the MJPEG offering ! Encoding Video Data 26
  • 27. Overview of the MJPEG offering ! JPEG/MJPEG SDK includes stand alone Encoder and Decoder Libraries " http://www.analog.com/blackfin/codeExamples " Access to all source code, except the actual encoder and decoder algorithm (libraries provided) " Examples based entirely on ADI’s System Services and Device Driver libraries ! Other Resources " ITU-T, “Information Technology- Digital Compression and Coding of Continuous-Tone Still Images- Requirements and Guidelines”, " ADI, “JPEG Encoder Library Developer's Guide” " ADI, “JPEG Decoder Library Developer's Guide” " ADI, “MJPEG AVI Library Developer’s Guide” 27
  • 28. MJPEG Encoding Video Data Basics ! An Inbound buffer is processed/compressed by MJPEG codec " MJPEG Codec Encodes a 4:2:0 Video buffer comprised of Y, Cr, Cb Buffers Compressed Video Y MJPEG Encoder Cr Cb ! Memory DMA is often used to separate and down sample 4:2:2 interlaced image to a progressive YCrCb 4:2:0 format " Down sampling the Cr and Cb components by two in the vertical direction " Callback typically initiates Memory DMA action Video_Frames[0] Blanking Field 1 Y Active Video MJPEG Blanking MemoryDMA Y/Cr/Cb Field 2 Encoder Active Video Cr Cb Blanking 4:2:2 Format Compressed 4:2:0 Format Video 28
  • 29. Initializing MJPEG Codec ! Configure MJPEG Codec " JPEG_FRAME_WIDTH, JPEG_FRAME_HEIGHT, JPEG_QUALITYFACTOR, etc. Quality Compression Horizontal Vertical Frames/Sec Factor Ratio Cycles/Pel Mhz Required 176 144 30 60 10.3 53.89 41 176 144 30 40 13.1 49.08 37 640 480 30 60 14.0 43.68 403 640 480 30 40 19.2 38.7 357 *For more details and other benchmarks look into the documentation (Developer Guides) that comes with the software product brief for JPEG/MJPEG SDK ! Allocate the output streambuffer " StreamBuffer_Obj = JPEG_MemAlloc_NEW(3 * Input_Width * Input_Height,1,MEM_TYPE_DATA); ! Typical application would streaming output to local file system (i.e. fprintf) or remote host file system. ! Instantiate JPEG Encoder " lJpegEnc = JPEG_Encoder_NEW(&lImageParam); 29
  • 30. Encode Video ! Step 1: Wait for full YCrCb 4:2:0 Buffer ! Step 2: Pass YCrCb 4:2:0 Buffer Pointer " JPEG_McuBuffer_CONFIG(mcu_ex, MCU_POINTER_C1, (unsigned int)lInputBuffer); ! Step 3: Perform MJPEG Encode " JPEG_EncodeSequentialImage(lJpegEnc, &NumBytes); ! To encode next frame, go to Step 1 Video_Frames[0] Compressed Video (contains multiple Blanking frames of data) Field 1 Me Active Video mo Blanking ryD Field 2 MA Active Video Y/C Y Blanking r/C b MJPEG Video_Frames[1] Encoder b Blanking r/C Cr Cb Field 1 A Y/C Active Video M Blanking ryD YCrCb 4:2:0 mo Buffer Me Field 2 Active Video Blanking 4:2:2 Video Frames in SDRAM ! Without Double Buffering, frame being encoded is also being overwritten with new data – result is corrupted image 30
  • 31. Encode YCrCb 4:2:0 Frame with Double Buffering ! To encode multiple frames, double buffering is used " Ensures previous frame which is being encoded isn’t corrupted with next frame data ADSP-BF561 Video_Frames[0] Compressed Video Blanking Y (contains multiple Field 1 En frames of data) Active Video co Memory DMA Y/Cr/Cb de E0 Blanking F ram AM Field 2 Cr Cb FR Active Video e0 L MJPEG FIL Blanking PPI0 ADV7183B ADC FIL Video_Frames[1] Encoder LF e1 Video Source RA Blanking ram ME Field 1 eF Active Video Y od 1 E nc Blanking Memory DMA Y/Cr/Cb Field 2 Active Video Blanking Cr Cb Video Frames in SDRAM 31
  • 32. Outline for USB Sub-module ! Blackfin USB-LAN EZ-Extender ! Simple Blackfin-Host Data Transfers over USB 2.0 32
  • 33. Blackfin USB-LAN EZ-Extender Hardware ! Adds USB 2.0 High speed connectivity to Blackfin " PLX NET2272 USB 2.0 High Speed Controller ! USB-LAN EZ-Extender plugs on to ADSP-BF533, ADSP-BF537, and ADSP-BF561 EZ-KITs 33
  • 34. Blackfin USB-LAN EZ-Extender Benchmarks Processor OUT -> from IN <- to host host MBytes/sec MBytes/sec BF533 20.0 25.1 BF537 20.3 25.0 BF561 16.3 20.0 ! Test Conditions " Using the provided host application, bulk host driver, and firmware " Test system: P4 2.0 GHz, 768 MB RAM, USB 2.0 host controller, WinXP Pro SP2, no other USB devices on the bus " Measure on Windows and takes into account complete transaction time from host application point of view 34
  • 35. Simple Blackfin-Host Transfers Via NET2272 USB ! Receive USB command block from the Host indicating what function for Blackfin to perform ! Perform IO Based on Command using File I/O or Stdio " UploadData payload to Host PC " Download Data payload from Host PC ADSP-BF561 USB Commands USB EBIU NET2272 Payload Move Data Payload Memory 35
  • 36. Basic Commands Overview ! Application exchanges command blocks with the host " Indicating what functions to perform " Refer to USBCMD.h for default USBCB command block structure Example: typedef struct _USBCB // USB command block { ULONG ulCommand; // command to execute ULONG ulData; // generic data field OR 1st Parameter ULONG ulCount; // number of bytes to transfer OR 2nd Parameter ULONG ulPar3; // 3rd Parameter ULONG ulPar4; // 4th Parameter } USBCB, *PUSBCB; 36
  • 37. Basic Commands Usage ! USBCMD.h also contains default Commands enum _USB_COMMAND { NO_COMMAND, // nothing to do here... GET_FW_VERSION, // get the firmware version QUERY_SUPPORT, // query for support QUERY_REPLY, // query reply LOOPBACK, // run loopback on the device MEMORY_READ, // read from specified memory on the device MEMORY_WRITE, // write to specified memory on the device USBIO_START, // run USB IO on this device USBIO_STOP, // stop USB IO on this device USBIO_OPEN, // open file on host … }; ! Once Command has been received, switch on the command received " switch( pusbcb->ulCommand ) Example: switch( pusbcb->ulCommand ) { case USBIO_START: PerformIo( USB_DevHandle ); break; // perform IO over USB case MEMORY_READ: ReadMemory( USB_DevHandle, (u8*)pusbcb->ulData, pusbcb->ulCount ); break; // read memory case MEMORY_WRITE: WriteMemory( USB_DevHandle, (u8*)pusbcb->ulData, pusbcb->ulCount ); break; // write memory default: exit(1); break; // unsupported command } 37
  • 38. Additional Inforamation on Blackfin USB ! Hardware schematics and layout data available on ftp site " ftp://ftp.analog.com/pub/tools/Hardware ! Blackfin USB firmware " Ships with latest VisualDSP++ " C language examples - loopback and IO redirection " C language NET2272 driver – bulk and isochronous versions ! Windows host application " Shipswith latest VisualDSP++ " C/C++ example built with Microsoft Visual Studio .NET 38
  • 39. Rapid Development of a MJPEG Video Encoder 39
  • 40. Rapid Development with Common Components ! Video-In ! Video-Out ! MJPEG Encoder ! USB Host ADSP-BF561 Video_Frames[0] Blanking Field 1 Active Video Di sp Blanking lay E0 FR AM Field 2 AM FR Active Video L Blanking E 0 FIL PPI0 PPI1 ADV7183B ADV7179 Decoder Video_Frames[1] FIL Encoder LF Blanking 1 RA Field 1 ME ME Active Video F RA 1 y pla Blanking Field 2 Active Video Dis Blanking Video Frames in SDRAM Compressed Video (contains multiple frames of data) Y USB Commands Cr Cb MJPEG USB EBIU Y Encoder NET2272 Memory Cr Cb Move Data Payload 40
  • 41. Software Flow Setup MJPEG Parameters and OPEN remote file (‘MJPEG_Encode.c’) ADV71783B Setup System Device Driver Services (‘main.c’) Setup Video Devices ADV7179 ADV7183B and ADV7179 Device Driver (‘MJPEG_Encode.c’) NET2272 Device Driver Setup NET2272 Device (‘main.c’) Press SW6 on NO EZ-KIT to START? SW6 is arbitrary. For example, could (‘MJPEG_Encode.c’) be motion activated sensors which kicks off MJPEG encoding YES New USB NO command? MJPEG Encode Video (‘main.c’) MJPEG Frames as they become LIBRARY available YES (‘MJPEG_Encode.c’) Identify MJPEG Coding_Algorithm and Perform IO of Coding_Action (‘main.c’) compressed MJPEG image data over USB (‘MJPEG_Encode.c’) Perform MJPEG action and send Encoded image over USB Press SW6 on NO EZ-KIT to STOP? (‘main.c’) (‘MJPEG_Encode.c’) YES CLOSE remote file 41 (‘MJPEG_Encode.c’)
  • 42. What’s Required ! Hardware " ADSP-BF561EZ-Kit (Silicon Revision 0.3 or higher) " ADSP-USB_EZ_LAN Extender Card " PC ! Running WinXP ! Native USB2.0 port is best − If you do not have, use a PCMCIA plug-in card. Transfer rate will degrade by ~30% " DVD player (NTSC) for input " Display (NTSC) for output ! Toolset " VisualDSP++ 4.0 with December 2005 update and Emulator " If you don’t want to recompile, use the provided *.dxe executable or burn the provided *.ldr image into flash memory ! Software " ZIP file " Posted with this presentation 42
  • 43. Installation [1/4] ! Copy or extract the Software into a directory on your hard- disk (let’s call it “ROOT” directory) ! Connect Extender Card onto ADSP-BF561 EZ-kit ! Connect USB2.0 port on PC to USB2.0 port ON THE EXTENDER CARD ! Set DIP switches according to table on next Slide 43
  • 44. Installation [2/4] Setting for this demo EZkit DIP switches SW3 All off except #6 SW9 All off except #1 and #6 SW2 All off SW1 All off Extender card DIP switches SW1 All on except #4 SW2 All on except #1 44
  • 45. Hardware System Overview (MJPEG Encoder) Simple Video Pass Through ADV7183B ADV7179 ADSP-BF561 EZ-KIT BF561 (MJPEG Encoder) USB NET2272 EZ-USB EXTENDER USB 2.0 to Host PC - Compressed Video flows from Blackfin to Stack EZ-USB Extender onto Host PC ADSP-BF561 EZ-KIT -*.AVI files get stored to local hard drive 45
  • 46. Installation [3/4] ! Connect the NTSC display to the “Video Out” Connector J6 on ADSP-BF561 EZ-Kit ! Connect the NTSC DVD player to the “Video In” Connector J6 on ADSP-BF561 EZ-Kit ! Power DVD Player and Display J6 on ADSP- BF561 EZ-Kit 46
  • 47. Installation [4/4] ! Power the EZ-Kit ! Start VisualDSP++ ! Load the Image File into flash memory " Use VisualDSP’s “flash programming tool” " Image file is “ROOTcodec_blkfnjmjpeg_appBF561bin ! Exit VisualDSP++ and reset the EZ-kit ! Windows should now detect a new USB Device " Follow the prompts to install the device driver " Specify the path to the device driver " DeviceDriver is located in “ROOTcodec_hosthostdriver” directory " This step needs to be done only once " Windows will remember device driver next time 47
  • 48. USAGE [1/3] – General ! Open a DOS prompt Terminal on your PC ! Generally under Start->All Programs->Accessories ! Change Directory to “ROOTcodec_hosthostapp” directory ! With DOS’s “cd” command (if necessary, switch to the hard-disk drive by typing “C:”) ! The “hostapp.exe” application is the main control for the Demo Application that is running on the DSP. !A few tests: ! Type “hostapp –h” and press “enter” - what happens? ! Type “hostapp –a” - will tell you if and how many DSPs are connected ! Type “hostapp –v” - more information about the application ! If the “hostapp” detects a device, you are ready to proceed! 48
  • 49. USAGE [2/3] - General A few general explanations: " Open an Explorer Window at " “ROOTimages” − Call this the “work directory” " “ROOTimagesMJPEG” − Target directory where encoded MJPEG *.AVI files will be stored The application uses File I/O to upload Payload to the Host PC " DISPLAYs information about the encoding/decoding process " Follow instructions on the terminal CAREFULLY " DO NOT TYPE in the terminal unless instructed to " Accidentally press a key at the wrong time will abort the program. Just press the reset button on the EZ-kit 49
  • 50. USAGE [3/3] – MJPEG ENCODER ! Open the specification file in the work directory ! mjpeg_encoder_spec.txt ! Each line specifies a target MJPEG (*.avi) file to be encoded from a Video source ! Type the name: for instance mymovie ! Type the size (Horizontal Vertical): for instance 320 240 ! Type the encoding quality factor (0 [least] – 100 [max]) ! Repeat for as many recordings/files you like to take Example: DISPLAY_MPEG_TEST1 352 288 60 DISPLAY_MPEG_TEST3 640 480 70 ! Save the file ! Run ENCODER from the Host PC terminal: ! Type “hostapp –m e” - Sets the DSP application to (m)jpeg (e)ncoding ! Type “hostapp –u” - Starts encoder application " NOW (as instructed) press button on the EZ-kit ! Press to start recording ! Press to stop recording ! Press ENTER on the keyboard to move to the next file ! Repeat for each file you specified in the steps above ! Play the files ! " Find files specified above in MJPEG directory in the work directory " Play the files by double-clicking on them 50
  • 51. Additional Information ! Blackfin USB firmware " Ships with latest VisualDSP++ " C language examples - loopback and IO redirection " C language NET2272 driver – bulk and isochronous versions ! Windows host application " Shipswith latest VisualDSP++ " C/C++ example built with Microsoft Visual Studio .NET ! For questions, click “Ask A Question” button or send an email to Processor.support@analog.com 51