msm: vidc: Add msm video core driver

commit 72d9968a380b41386631d83bbca4f02fe87658c8
Author: Arun Menon <menon@codeaurora.org>
Date:   Wed Dec 26 22:09:02 2012 -0800

    msm: vidc: rename functions in hfi layer to hardware specific

    The V4L2 video driver hfi layer would be supporting
    Venus hardware and Q6 firmware for video encode\decode.
    So renaming the functions specific to Venus and common
    functionality accordingly.

    Change-Id: Iaacf44bfe4fd5735fe5e82f335e01e8a314f6575
    Signed-off-by: Arun Menon <menon@codeaurora.org>

commit 2f39048f9e548d11134ae686549f92283e23d319
Author: Arun Menon <menon@codeaurora.org>
Date:   Wed Dec 26 15:43:01 2012 -0800

    msm: vidc: move vidc resources inside hfi layer

    As a part of V4L2 video driver restructure, hardware
    specific resources such as ocmem, bus bw requests are
    moved inside hardware specific hfi layer. This is needed
    since same V4L2 video driver will be supporting video
    decode\encode on both venus and Q6 hardware.

    Change-Id: I35eef5051d07ba36f61eded3c58018fde28ca57d
    Signed-off-by: Arun Menon <menon@codeaurora.org>

commit bf94306622a59f35d4e0079e5df4ee60cedafe0c
Author: Arun Menon <menon@codeaurora.org>
Date:   Tue Dec 18 14:13:15 2012 -0800

    msm: vidc: create common packetization module

    Venus and Q6 host firmware interface (hfi) share common
    packet interface. The hfi_packetization module
    will be used by both Q6 and Venus hfi layers to create
    packets.

    Change-Id: I74d89d8568315a8e21fa07179eeeb1d9132048e9
    Signed-off-by: Arun Menon <menon@codeaurora.org>

commit d9223b518a19e40e306523b42678e3d1518673be
Author: Arun Menon <menon@codeaurora.org>
Date:   Mon Nov 5 13:56:04 2012 -0800

    msm: vidc: Rename hal files to hfi

    The v4l2 video driver will be supporting multiple
    Host Firmware Interface (HFI) layers, so renaming
    generic file names to hfi specific ones.

    Change-Id: If96e23619fc28a03841e9e41470d1de86406ad2f
    Signed-off-by: Arun Menon <menon@codeaurora.org>

commit ed7d1fa26f4ec8f263c63a926e6a5308ab4066bf
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Dec 14 16:22:08 2012 -0800

    msm_vidc: Add support to log Firmware debug messages

    Driver need to configure the debug mode to
    Venus firmware. Venus firmware won't send any
    messages to driver without this setting.
    This change fixes the same.

    Change-Id: I24cac6054afc65b9672bb5b294d641053ddd87ea
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit c66cd9a1ae4933b1585d381bfd44f36b9632deb6
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Dec 14 14:53:54 2012 -0800

    msm_vidc: Notify subsystem framework of venus subsystem crashes

    The subsystem framework will use this information to do
    housekeeping work on the subsystem like taking ramdumps
    (if enabled) when the next subsystem_put() is called, etc.

    Change-Id: I5b76acde223e46c04b51a6b84950f4d59566c8c7
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 484fa46427fddc8f72758b90b7646317cf688e32
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Dec 14 15:17:00 2012 -0800

    msm_vidc: Handle venus watchdog timeout

    Handle venus watchdog timeout by informing all
    clients about the error so that existing video
    sessions can be closed.

    Change-Id: I631e319c810d8114050b21038e2f9edbbaf7427e
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit ca878a968d466b432cfec23935bbeb10c9855d33
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Dec 14 13:57:54 2012 -0800

    msm_vidc: Remove SSR related code

    Remove venus subsystem restart related code as this
    code is obsolete now after architecture changes in
    subsystem restart framework.

    Change-Id: I429f5d6ccf6d0a6f0d2513fb0e52c2ed0206e77d
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 86aa0d6de817dbd4e9bd8a009621f297a7349aaf
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Dec 14 00:29:33 2012 -0800

    msm_vidc: Add support to send EOS NAL

    If FW detectd End Of Sequence through NAL unit, it
    sets a flag in FBD message. Add support to process
    this flag and convey to userspace.

    Change-Id: I1224199b0a0db727278898e6d8ef2bb49f814d57
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 1d498a8d96fd01691a1c05809feeb50cc881ec7e
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Oct 18 17:08:17 2012 -0700

    msm_vidc: Update bus bandwidth request to support 4kx2k resolution

    when running 4kx2k videos, video driver was not requesting enough bus
    bandwidth, resulting in low performance. This change updates bus
    request for both encoder and decoder.

    Change-Id: Ic5458338443d777ce3b9a274677c10a62581e9a2
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 9c52fe1998e67983e548a384b2ce6cf620a53fe2
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Wed Dec 12 15:40:56 2012 -0800

    msm_vidc: Add error check for clock scaling.

    Clock scaling uses timestamp to determine the current fps.
    Timestamp for some frames might be invalid and shouldn't
    be used to calculate the fps. Add a check to handle this case.

    Change-Id: I8c570b131d11b1d2644806714fe2a726ca155eb5
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit aed3021f83932b0bc50ff52e6bc0b088a58c4223
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Tue Dec 11 18:27:23 2012 -0800

    msm: vidc: Numerator of timeperframe should be in seconds

    Currently we're treating the numerator of timeperframe as microseconds.
    This is contrary to the V4L2 spec, hence treat it in units of seconds.

    Change-Id: Id934e38c055fe8977557cd6ed464051330607439
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit d08430e2ffad551f7b99e591aab83c05060d278d
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Tue Oct 23 15:23:38 2012 -0700

    msm: vidc: Deprecate V4L2_CID_QCOM_VIDEO_SYNC_FRAME_SEQ_HDR

    Removing the vendor specific control V4L2_CID_QCOM_VIDEO_SYNC_FRAME_SEQ_HDR
    in favour of the more standard V4L2_CID_MPEG_VIDEO_HEADER_MODE.

    Change-Id: Iae2b357f23bbcd68af5b38fcbb08d97763dd1dc4
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit 05c648e741255b2f7138f801496412a2ef3ccccc
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Wed Dec 5 18:03:25 2012 -0800

    msm: vidc: add support for V4L2_CID_MPEG_VIDEO_HEADER_MODE

    Add support for V4L2_CID_MPEG_VIDEO_HEADER_MODE, which changes the
    interface by which userspace can request for the video header.

    Change-Id: I412316c5173d677b2797b6b30f91dc0ead596718
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit 5b624bbfabfafa36c443d9b36d5912979eeb753f
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Mon Oct 22 19:09:10 2012 -0700

    msm: vidc: Allow client to set only bitrate mode

    Add support for V4L2_CID_MPEG_VIDEO_BITRATE_MODE which is a standard
    V4L2 control.  This precedes the custom QCOM specific control which only
    allows the client to set the bitrate and the framerate.

    Change-Id: Idb2bef8f5b10a2d72c0d02be628f67eb878826c7
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit 5084a757570b3ee5220442721d0bbff5787fe31f
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Mon Oct 22 16:21:28 2012 -0700

    msm: vidc: Add support for setting I-frame period

    Add support for the V4L2 standard control for setting I-frame period.
    Thus far, we've only had support for setting the IDR-frame period.

    Change-Id: I877ec596d9056dd24384718bcb397bc5b8e6eede
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit 2c2836fb7572d2d5eeaf622fddb4f44734d2d860
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Mon Nov 5 18:39:43 2012 -0800

    msm: vidc: Group controls into clusters

    Organize related controls into clusters.  This commit does away with
    hacks to store values of related controls in static structures which
    inhibit concurrency use cases.

    CRs-Fixed: 414261
    Change-Id: I7347a8c10b57be22be34d88b0a1a7bca5ce8b8a1
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit d7cd510da3eff4645227144c2d33fcda074443f3
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Tue Oct 30 19:20:54 2012 -0700

    msm: vidc: Add support for decoder dynamic clock scaling

    Add support for dynamic clock scaling by calculating the
    decoding fps. Fps is calculated using input timestamps.

    CRs-fixed: 405399
    Change-Id: I0f09d902a3d44a9b93540ed652f872baf8ef8264
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 37529ad4569b2ab42d5b5690b6b286da58491b3b
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Dec 7 15:20:23 2012 -0800

    msm: vidc: Fallback to IOMMU heap

    Video buffer allocation falls back to IOMMU
    heap if MM heap runs out of memory. This helps
    reduce MM carveout size while supporting higher
    resolution encoding/decoding.

    CRs-fixed: 420585
    Change-Id: I3b71a722cbff3bcac32fdd3d74908685870d51ad
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit d9db1c618b1804eab402129878d710cd70a0f5c8
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Thu Dec 6 16:44:33 2012 -0800

    msm: vidc: Print buffer address in hex

    Print buffer address in hex for readability.

    Change-Id: I8c747701b5a6f8c1669ad31537721954af135594
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit eea3cc694bfd3af1ba2643585a06736397543157
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed Dec 5 17:38:36 2012 -0800

    msm: vidc: Driver cleanup on receiving SYS error

    SYS errors reported by firmware are handled properly
    and reported to client. On receiving SYS error client
    tries to close the driver. Cleanup in such scenarios
    was not proper. This change fixes that.

    CRs-fixed: 420316
    Change-Id: Ied7303bc2ecf4def6241dc7a37eceb1265417c2e
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit d8e3de6042849eab31df3d6ee4486dcb356eda3f
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Nov 16 17:31:30 2012 -0800

    msm: vidc: Add error check before calling release buffers to FW

    Release buffers can be called in any FW state. If release
    buffers called in non-release reources state, the FW might
    use them whereas the driver will unmap them causing IOMMU page fault.

    Change-Id: I21e7ac3e696594c0a802bd6066ef7a9a3ab9f12b
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit cc8192a0ace8ddd5bd44adca3347ff98296309a1
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Wed Nov 28 17:08:27 2012 -0800

    msm: vidc: Fix NULL pointer exception

    The error check to validate the device open failure has an
    issue where it is checking the wrong variable. This lead
    to NULL pointer access. This change fixes the same.

    CRs-Fixed: 417092
    Change-Id: I635fc43b19a368c2477ab41c9d6d28ec9dc8524e
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 949c2524f9c8d3cf9dd9cf558c0a2cfd2dd2789f
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Nov 8 18:33:18 2012 -0800

    msm_vidc: Fix race condition during buffer release

    Firmware accessed buffers when driver was freeing them. To avoid this
    race condition, firmware now acknowledges release buffer command. Driver
    will wait for this response before releasing the buffers.

    CRs-fixed: 417952
    Change-Id: I1d28103fb4aa8ef55b3d3665a7202284887ae6f6
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 25731c7b1b5a36284729821c0f906392f000a4d6
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed Nov 28 12:36:01 2012 -0800

    msm: vidc: Vote for DDR BW before FW download

    Vote for DDR bandwidth before downloading video
    firmware so that as soon as hardware is brought
    out of reset it is able to access firmware. Not
    doing this might result in IOMMU page faults
    on starting video playback or recording.

    Change-Id: I91ecdcdc4c57765f848f75ae6f476cee46a16829
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 7765f8331fe55363c35f3a28592bea064db6fbb1
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed Nov 28 12:58:26 2012 -0800

    msm: vidc: Align secure buffer mappings to 1MB

    Secure buffer mappings should be aligned to 1MB
    for the mappings to succeed. This change takes
    care of that.

    Change-Id: I963df71271b9b24191ac94203d36a25fec90cdbf
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 4e4922b4c17353c60b5b89fb4ed32d81b9868dd1
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Tue Nov 27 12:17:11 2012 -0800

    msm: vidc: update driver for firmware interface changes

    This change updates the driver with the new FW interface
    changes. FW modified various packet structures. So the
    changes have made to update the driver accordingly.
    The changes are backward compatible so these work
    with old FW as well.

    Change-Id: I6b34eb1282c74b2ac4a5dd7fc4b4435b9517070b
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit bdcbe380dd07e711a20dbbc6da79768a8f2a6cbf
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Nov 26 21:01:52 2012 -0800

    msm: vidc: Unvote for bus BW after unloading FW

    Driver should unvote for bus bandwidth after all
    transactions are completed. Unvoting after unloading
    firmware makes sure there are no outstanding transactions.
    Without this change, stability of video playback might
    be impacted when video is played back to back.

    CRs-fixed: 419402
    Change-Id: I821f941183fc24ba65d6f17b3f39354e0d77b4bf
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 60802d92c6c96dd57c9b2d988dc3334e731c83fe
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Wed Nov 21 14:53:35 2012 -0800

    msm: vidc: Use proper msm_vidc_core when handling SYS_ERROR

    When handling SYS_ERROR use device_id to determine the core rather than
    find the core via the instance (contained with in session_id).  The
    firmware does not respond with the proper session_id in cases of
    SYS_ERROR.

    When handling SESSION_ERROR pass through the session_id returned by the
    firmware, so that the instance can be cleaned up properly.

    Change-Id: Ic38feb0878579403a1c8e108f18d46bea2891795
    CRs-Fixed: 419792
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit af26b337d6d092106c2fa099b2ed1a8cd3cf43af
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Nov 12 11:50:49 2012 -0800

    msm: vidc: Add control to enable extradata

    Add control to enable extradata. Client can use this
    control to enable a particular extradata for gathering
    additional information about the associated buffer.

    Change-Id: Ib39c614997cd43bee68fccac00d623ddd8caaf9b
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 110e12cc3807af1401986147e6b8371c0c38518e
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Mon Nov 5 12:24:57 2012 -0800

    msm: vidc: Add change in error check for FW buffer requirements

    FW buffer requirements for some buffers can be zero.
    Driver treat them as an error and returing bad buffer
    requirement which are actually valid.Add a fix to
    process the FW buffer requirement correctly.

    Change-Id: I7116fe5a03be77d10b1ecab737f0f3504377f80f
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit b0c1a9ae734a67a45e519bd67c5a1e7d9cbbea46
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Nov 9 15:44:03 2012 -0800

    msm: vidc: Add fix to update capture port buffer size

    If the resolution changed and no port reconfig, the
    V4L2 framework and driver have different capture port
    buffer sizes. Due to this mismatch the buffer is rejected
    by V4L2 framework.Add fix to update the buffer size.

    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
    Change-Id: Ib2ed5684aa10d13a614a3e213afb449d1c3dee8c

commit 6c03c29dbb9e70d172674c33391daff210710db9
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Tue Nov 13 13:35:25 2012 -0800

    msm: vidc: Fix a bug in state transition

    Fix a bug in state transition in driver. Without this
    fix some of the buffers were not released on firmware
    in following scenario:

    1. Video device is openend.
    2. Buffers are allocated.
    3. Video device is closed.

    This change fixes this issue.
    CRs-fixed: 419927

    Change-Id: I5f27b047971bcf1fb85e45a8c9d9938e177a4de5
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 6472cd488fe6f5d59b442745700f0f88f4318a35
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Thu Sep 6 14:12:34 2012 -0700

    msm: vidc: Changes for secure video playback

    Changes required to protect and unprotect buffer
    memory for secure video playback.

    Change-Id: Ia918e35142852b9cb51275972692914d4b78bfb9
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit d4497883dad4e34d0755cb7585db1088c2fb969e
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Mon Nov 12 17:57:31 2012 -0800

    msm_vidc: venc: update input buffer count for firmware

    Setting max buffer count to firmware and later querying the buffer
    requirements after setting resolution and other properties will result
    in firmware returning max buffer count. To avoid allocating extra
    buffers, this change sets firmware with the max buffer count
    requested by client and firmware.

    Change-Id: I3d5e800ea3cdea4064d4e9d8453eb4d925c77f8c
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 0eaa2266918bb65a89d2a7df0ebb20aebf76c590
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Fri Nov 2 11:57:55 2012 -0700

    msm_vidc: update driver for firmware interface changes

    This change updates the driver to the new firmware requirements.
    Since, FW interface has changed significantly so pre-existing driver code
    does not work with this firmware. This change is a must for driver to
    work with new firmware. After this change, old FW will not work with this
    driver.

    Change-Id: I2f8408dd46909f7f527252410655c6fa919c465a
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 3823bbcf8132561b8da5a76d33d5bd2d143b3d82
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Oct 25 15:36:22 2012 -0700

    msm_vidc: Update firmware of input buffer count for video encoder

    If video firmware is not aware of input buffer count, and driver
    queues more buffers than firmware is aware of, this results in
    firmware crash. This change updates firmware of updated input buffer
    count.

    CRs-fixed: 411057
    Change-Id: I5713a300636071db80f532029cf81c3b88db0789
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 9e2d8826d1b6c7c7a7ccfd8da908af68a5a808aa
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed Nov 7 16:23:05 2012 -0800

    msm: vidc: Fix a bug in free_irq

    Free irq should not be called with NULL but instead
    it should be called with hal_device.

    Change-Id: Ic45fbec37ab1c3d3ec877a0f89c7e1c7a1834f59
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit c4e0e5de4869c0bc3c91fddb0657c93bc997b324
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Tue Nov 6 15:50:10 2012 -0800

    msm: vidc: Remove SSR init/uninit calls

    SSR architecture has changed so driver does
    not need to call ssr init/uninit anymore.
    Changes need to be made according to new
    architecture. Removing the old code.

    Change-Id: I5a4334a4da604a78775864a310f2a12378a8de83
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 57860a865d0f91e0c40645c7d8dc0e2b9143936e
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Thu Nov 1 11:52:28 2012 -0700

    msm: vidc: Add support to process FW errors

    Adds support to process system and session
    errors received by FW and communicate them to
    client.

    Change-Id: Iddcb8f0b8a459cf7185e56121ffcbd6a3532e365
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 36f8d36a1fd675741df5e76e030c6bfc09bc6d17
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Oct 18 17:01:06 2012 -0700

    msm_vidc: update vbif setting for video hardware

    Update vbif registers to improve encode and decoder performance
    on 8974.

    Change-Id: I297968273c6acd8d753c310a34f24fa978a6e5f2
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit ff9c23f98a888f7acfe4416f9fd166e876e8d490
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Oct 26 13:09:10 2012 -0700

    msm: vidc: Fix iommu detach and pil_put order

    IOMMU detach should be called before subsystem_put.
    This change takes care of it.

    Change-Id: Iece3f548a152a443705223725763cb8ef6e37b80
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 72f479db62c0cec8080183d2171bd1967ba2598b
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Wed Oct 31 15:30:25 2012 -0700

    msm: vidc: Remove SSR trigger for SYS error

    Firmware is incorrectly sending the SYS error
    for nonfatal error cases. This is causing
    the SSR trigger for invalid scenarios hence
    removing this trigger until it is fixed in
    firmware.

    Change-Id: If98a1b07d071a8c903fe2c6addf01747745c0ae5
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 71b7ba92ed4d143bf1ff3e6a38ab362a56e8775f
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Tue Oct 30 15:41:02 2012 -0700

    msm: vidc: Add support to process resources request from HW

    Add support to process resources request from HW based on
    smooth streaming flag.The client is updated with the
    updated resource request.

    Change-Id: Id95321f6894a903c23d25ee33835bcd1efb36d29
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit c1a7261dcaed73a2023ed4f43df12a13cc77991d
Author: Stephen Boyd <sboyd@codeaurora.org>
Date:   Thu Jul 5 14:07:35 2012 -0700

    msm: ramdump: Add parent link to miscdevice

    Set the parent of the miscdevice created in
    create_ramdump_device() to be the platform device for each
    processor. This allows us to easily locate ramdump devices for a
    particular processor.

    Change-Id: I7241e57231ad3f6a60d799be094d2b7a7fc40a3d
    Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

commit 77db8bb9741de2d09f52947a7f6dff89110f3f99
Author: Stephen Boyd <sboyd@codeaurora.org>
Date:   Wed Jun 27 15:15:16 2012 -0700

    treewide: Replace pil_get()/put() with subsystem_get()/put()

    Do a tree wide sed to replace pil_get and pil_put() with their
    subsystem counterpart. With all the pil drivers migrated over to
    the new subsystem start/stop API this is essentially a no-op.

    We rename "q6" to "adsp" to be more in line with how future
    chipsets name the low power audio subsystem. This requires minor
    changes to userspace; hopefully no more changes will be
    necessary.

    Change-Id: I22dbbdcf7f5aaaa80394a6d70b5cfc24cdb32044
    Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

commit 6c51b6e489752a0f92e9e446625c79504028ec44
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Oct 15 15:18:04 2012 -0700

    msm: vidc: Add header file for sharing media info

    Create a common header file which can be used across
    mulitmedia subsystems for sharing static information
    between them. One such requirement is to share information
    related to video color formats. This common header file
    avoids duplication of same calculations across different
    drivers and userspace.

    Change-Id: I4cb70c6b2461cc4dfcabcf147f0f314c5cf6a8bd
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 9cb13cccc47d197987f750ad3096aa0dcf583d64
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Oct 29 12:58:57 2012 -0700

    msm: vdec: Handle no-extradata case for video.

    Firmware or client may request for no extradata.
    In such scenarios we have to ignore the extradata
    and let the session go ahead without extradata as
    extradata is not required.

    CRs-fixed: 415351
    Change-Id: I2b58303172552a0e1aa78e71e5b91e2d80d084e9
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 1f0c265bb1da311601f2c1d20baca4506450d1aa
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Mon Oct 22 15:47:52 2012 -0700

    msm: vidc: Add support for dynamic clock scaling

    Adds support for dynamic clock scaling by calculating
    the number of mbs based on the frame rate set by client.

    Change-Id: Ie680bfc4ad536636a1e5793f15efbda1c73e5af8
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 4e303609cf8dc5c340e47224df37f54cf37b90a0
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Mon Oct 1 18:56:34 2012 -0700

    msm_vidc: venc: Release encoder buffers

    Video encoder session cleanup was not done completely, this
    change allows cleaning up of the scratch buffers and ensures
    firmware releases output buffers before driver frees them.

    Change-Id: I08e825376c81311c4235bbf7d6dd81de969bee73
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 74932576309bf985c3b985f2e88912ff90f8ecaa
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed Oct 24 18:54:13 2012 -0700

    msm: vidc: Fix iommu unmap and iommu detach order

    Free any outstanding memory allocations and unmap
    IOMMU before IOMMU is detached.

    Change-Id: Id750db5be260cfdb07e4db013635f94bd120a755
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit a2692a1946b0365c6c335315ced32c9ef4f4d201
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Thu Oct 18 19:23:29 2012 -0700

    msm: vidc: Add logs to indicate video open/close

    Add logs to indicate when video is openend and
    when it is closed. This helps a lot in debugging
    complex issues where multiple instances of video
    are running concurrently.

    Change-Id: I043b248a6bf90bd9b328527782b3a406f6b7f577
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 131aaac36440b3a68bfd252c16adf85b55566f9b
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Tue Oct 16 17:30:22 2012 -0700

    msm: vidc: Add support for thumbnail mode

    Add support for thumbnail mode decode. This reduces
    the memory requirements from HW.

    Change-Id: I7f54cc618759b366389e748527b051524fb2c20b
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit e0368f062d399970940f1d16264f1874ac0a392a
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Wed Oct 17 16:41:14 2012 -0700

    msm: vidc: Change V4L2_CID_MPEG_VIDC_VIDEO_REQUEST_IFRAME to button type

    V4L2_CID_MPEG_VIDC_VIDEO_REQUEST_IFRAME should not be a boolean type as
    subsequent requests for I-frames will be dropped by the V4L2 control
    framework as a duplicate s_ctrl.

    Change-Id: I27b30d8626488dcf7164a4709551d817d607a8d7
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit 1efc291329375462538440baca9c47fcfad1aae2
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed Jul 25 19:52:17 2012 -0700

    msm: vidc: Add extradata support

    Uncompressed buffers can have extradata associated with
    them. This extradata contains information about the
    uncompressed buffer, eg: interleaving information,
    macroblock error information etc. With this change
    extradata buffers can be exchanged between firmware and
    client. If the number of planes in a  v4l2 buffer are more
    than one, then the last plane is considered as the plane
    containing extradata information.

    Change-Id: I4659d5a5749b0c1f4e32e17ccd5aecfbc4600f62
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit ed8ad3cee7f2a51f1b33cd22f8c391b1ff036727
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Tue Oct 23 16:17:50 2012 -0700

    msm_vidc: update performance calculations in video driver

    Performance calculation were not accurate, resulting in incorrect
    fps reported by driver. Updated the calculations to reflect correct
    numbers.

    Change-Id: I74813aa902332cb2fc088f353e3d1e47e223791d
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit cd2c13431063c20104ee1a07a60280b57f1d2623
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Thu Aug 23 11:59:09 2012 -0700

    msm: vidc: Add support to process HW Error

    Add support to process Watchdog timeout and sys error
    with SSR framework and reporting event bck to userspace.

    Change-Id: Ie12a15044dd01cb0ceab82d4f29d612db2955b8d
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 9df72b18a3fed5b0752812978a4713631d5eaed3
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Tue Oct 16 15:57:04 2012 -0700

    msm_vidc: update bus bandwidth selection for video driver.

    Incorrect bus bandwidth was selected for video encoder or decoder,
    resulting in performance being lower than expected. This change picks
    the correct value when requesting bus bandwidth.

    Change-Id: I76d8bc4e77430337e26aa394e6a3c1d0e5c8b79b
    CRs-Fixed: 406619
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 39f7889bd4d53480867cedd726aaabba4858ef9d
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Tue Oct 16 16:36:25 2012 -0700

    msm: vidc: On session_end_done only free current session context

    Currently, the msm_vidc driver is freeing the contexts of all the active
    sessions, causing hanging pointers and general memory corruption.  We
    should only be closing the context of the session that is ending.

    Change-Id: Ie7bbd5a5b31f79a3ed80bca84b4ec0cc7e6bb013
    CRs-Fixed: 407718
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit ae3e91a67f5d8e4a6aae55a9f7a0d9aad6b71215
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Fri Oct 12 17:37:37 2012 -0700

    msm_vidc: mask extra interrupts from video hardware.

    video driver was registering to receive all interrupts from video
    hardware, so video hardware raised multiple interrupts when
    processing a frame. This change masks interrupts which do not convey
    video information, thereby reducing the number of times video hardware
    interrupts the host.

    Change-Id: I861cad7cc217241bb804b808796863f566aedf6c
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 000b382c1ee984de63c1b63b8b88c01ed04282bd
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Oct 11 18:20:58 2012 -0700

    msm_vidc: reduce excess logging in video playback.

    Excess video driver logs sometimes causes system to crash/freeze UI.
    This change reduces the logs printed during session and fix incomplete
    messages.

    CRs-fixed: 408825
    Change-Id: I1da2f077e2254a813655792805d9bd26b1d63495
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit cde7852e58e7e6d55edca090d63a3b371e7336a8
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Jun 28 18:14:50 2012 -0700

    msm_vidc: enable firmware debug logs from video driver

    Firmware messages don't get printed to console. This change enables
    firmware debug messages and prints them as part of video driver
    kernel messages.

    Change-Id: Ie59a11ee127bbdf87e9ee1983ab52720aa427d27
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit ee1973ba0ea6c63ca781fd6a233411212df3c934
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Wed Sep 26 18:24:34 2012 -0700

    msm_vidc: Enable performance metrics calculations in video driver

    Add support for measure video core response time for command/data
    calls issued from driver

    Change-Id: I2d08cb65b2ef8cf2f977ae13870956413bd8e5fa
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 45648a4a5199e3fb2c8f9aca9e8c003d477c8aaa
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Wed Oct 10 18:58:54 2012 -0700

    msm_vidc: venc: set resolution on firmware in set_format call.

    Resolution information was saved in driver and set to firmware once
    before encoding starts, in one use case this lead to corruption. This
    change configures the firmware to update the resolution everytime
    client updates resolution.

    CRs-fixed: 408761
    Change-Id: I6b43d59c7e44b2e4f48d1fda061f006dc0faca55
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 6a8803fded6d41363efac47314efeb3f142248bc
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Tue Oct 9 18:41:49 2012 -0700

    msm_vidc: venc: set slice size to firmware.

    Slice size information was not propogated to firmware resulting
    in slice size = 0 for all slice enabled encodings. This change
    configures proper size to firmware.

    Change-Id: Ie87ac63791e3473aab98a7186364befbb2156128
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 1586fee7cb9f25516a4290a45a42b9568b9ebee2
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Oct 4 16:21:36 2012 -0700

    msm_vidc: venc: set correct count for input buffers.

    Input buffer count was not set properly for video encoder driver
    resulting in failure to start encoder session. This changes configures
    the encoder to pick maximum of the configured buffer count and updated
    buffer count.

    Change-Id: Ifc25eb930be758bf690d697638255a312b2f39c6
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit acff683704e6c952b6c8007f14f2f477db24118e
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Sep 27 18:06:01 2012 -0700

    msm_vidc: change logging mechanism in video driver

    video driver was logged all messages below given level, this change
    allows selective logging, and enables error and warning messages.

    Change-Id: Idf19bf9f4aa3d729506a32a5e781af7c7d6aa8ad
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 9105d4246637072b7cc9fe4a30cedf7889101324
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Thu Oct 4 18:11:24 2012 -0700

    msm: vidc: Adds fix to set the correct MPEG4 profile

    Fixes a mismatch of profile values between HW
    and vidc driver.

    Change-Id: Id82ab02445fa3f35e4dec5a1553fbecde6b307f7
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 99686cafd940a4734b527117a13a9100e6c24a68
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Thu Oct 4 10:14:21 2012 -0700

    msm: vidc: Clear pending buffer queue on flush

    If flush is called before streamon but after queuing the buffers
    then driver needs to return back the queued buffers. This change
    takes care of that scenario.

    Change-Id: Icab901ee0016c8033d113bc049cc1abbe01ed9e9
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 76b9b4d881b32c13356c736a07b2ee363d5ddd9b
Author: Mitchel Humpherys <mitchelh@codeaurora.org>
Date:   Mon Sep 17 14:33:22 2012 -0700

    ion: remove obsolete ion flags

    The symbols CACHED and UNCACHED have been replaced by ION_FLAG_CACHED
    upstream. This removes them from the kernel.

    Change-Id: I565dcc4595298ce6a0e81dd8cb98b86a1b38fdb2
    Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

commit 911b4b702a63fbd241863966cad45909e40e4665
Author: Mitchel Humpherys <mitchelh@codeaurora.org>
Date:   Wed Sep 12 14:42:50 2012 -0700

    ion: change ion kernel map function to not take flags argument

    Buffer flags are going to be specified at allocation time rather than
    map time. This removes the flags argument from the ion kernel map
    function.

    Change-Id: I91589ca7b1ab142bb5ac8e6b0f4c06fa1305f23a
    Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

commit 7d72bad55a0e03392d81eee77a9a8c9df6b73a9a
Author: Hanumant Singh <hanumant@codeaurora.org>
Date:   Wed Aug 29 18:39:44 2012 -0700

    ion: Port heap mask change to ion

    Heap mask field passes as argument at allocation time to specify ion
    heap.

    Change-Id: I8881dfc491dc0f8f70581ad97b35756a6a33dd6d
    Signed-off-by: Hanumant Singh <hanumant@codeaurora.org>
    Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

commit 227a6582d86ae918d290c208f30246b3756084fb
Author: Mitchel Humpherys <mitchelh@codeaurora.org>
Date:   Tue Sep 11 15:59:11 2012 -0700

    ion: change ion buffer flags

    This syncs up our ion buffer flags in ion.h with upstream (using
    ION_FLAG_CACHED instead of CACHED and UNCACHED).

    Change-Id: I0bca35210da403098a12747ddadb51fa399f8758
    Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

commit a67f6464ffbeccb97cc5c27cc704881bc8324e42
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed Sep 19 22:02:49 2012 -0700

    msm: vidc: Protect queued buffers list with lock

    Queued buffers list can be accessed across different
    threads so it should be protected with a lock. Without
    proper locking the lists might get corrupted resulting
    in frame drops and crash eventually.

    CRs-fixed: 400702

    Change-Id: Ie316b6744db342203e23a83bf6194983ea5eecca
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit cc2bb4d2164217b82fd0e36a84b1a8f309005ea9
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Sep 24 16:17:45 2012 -0700

    msm: vidc: Fix release buffers to prevent mem leak

    Fix a bug in release buffers and clean up code to reuse already
    existing functionality. Without this fix release buffers was
    failing which might result in memory leak.

    Change-Id: Iedaa19657b69883dd0c66654ada8f0e5bf2ec03f
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 2e542e4409b7a351dbfbe53d2256c3511cb63579
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Sep 24 14:28:19 2012 -0700

    msm: vidc: Unmap iommu in non-atomic context

    ion_unmap_iommu should not be called in atomic context.
    This change removes spinlocks around this call. spinlock is
    needed to protect the addition and deletion into the
    queues and it is not required while unmapping/freeing
    memory.

    Change-Id: I8a35f8d9c18302ce4761eda25f4238b66e948430
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 8c5f34fb8a5c98a827f0c70839cee3c2bfaf1d28
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Fri Sep 14 17:13:38 2012 -0700

    msm: vidc: Configure codecconfig param on video core

    When firmware sends syncframe, codecconfig is also sent along,
    this is default behavior. This means codecconfig is being sent
    multiple times resulting in parsing errors in container. This
    change configures firmware to not send the codecconfig data with
    syncframe.

    CRs-fixed: 396716
    Change-Id: If89aee60a16e422217ac9a7e7415d6448a068966
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit bddb1ebee894aa085db755bfd889b798f74e37c6
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Sep 24 18:01:57 2012 -0700

    msm: vidc: Fix IOMMU pagefault for long clips

    Shared command/message queues are circular, so if they get
    full driver has to write/read into them from the beginning.
    The address used to write/read from beginning was not the
    kernel virtual address causing IOMMU page fault.

    CRs-fixed: 400747
    Change-Id: Ie414f75370c31c8a4fb1bf7c879d1d0f4d5c7ea0
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 86449e6b5f9a803c730ef3988d67378b3d57c86e
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Wed Sep 19 15:24:33 2012 -0700

    msm_vidc: venc: Change default fps for Video encoder.

    V4L2 framework will not pass the fps information to firmware
    if new fps = current fps. This resulted as incorrect rate
    control setting to firmware. This change fixes the issue.

    CRs-fixed: 396793
    Change-Id: I69b66c2d06330cc00857a612f1f4e1f28a2eb2ec
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 00dd73ca7b3b8a0083596354dfe0295694399fd0
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Wed Sep 5 23:13:14 2012 -0700

    msm: vidc: Adds support to release buffers

    Adds support to release internal,scratch and output
    buffers at the end of the video playback and return
    them to userspace.

    Change-Id: Iffd2a09146f4129a97a9566432be8ddde9442308
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 106f5182c1344abff687477a7feabb231f7856ab
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Fri Jul 6 15:08:22 2012 -0700

    msm: vidc: Add msm_vidc_wait as a poll interface for kernel clients

    Add a new interface msm_vidc_wait that is similar to msm_vidc_poll in
    functionality, except intended for kernel-space clients.

    Change-Id: Ia08f228f9865dcb8c92ba8fc04692e4b0184daea
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit 7d12f84196c9f2f29f7ca92759502fe407bebe30
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Tue Jul 3 15:10:49 2012 -0700

    msm: vidc: Expose additional vidc interfaces

    Add additional interfaces to msm_vidc so that kernel clients may use
    them.  To enable this, msm_vidc_open() interface has been modified such
    that internal structs do not need to be exposed.  Furthermore, some
    functions such as (un)subscribe_event() have been moved from the v4l2
    layer to the vidc layer.

    Change-Id: If29154b8f542835e6c4ebf0be4c654474038c1ec
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit 2e2c63936972bbb4f004e2499485e2c67e62293f
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Sun Aug 12 01:43:14 2012 -0700

    msm: vidc: Adds support for VC-1 MP and SP support

    Adds support for VC-1 Main and Simple profile decoders
    by adding VC-1 decoder entry in vdec formats struct.

    Change-Id: I7b2bbaee6b84e7198f825a80aeb7c52a6271a9a5
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit ff92804047a2e3f7d75f7fc661779a93f9bc2c24
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Sep 14 18:33:45 2012 -0700

    msm: vidc: Reduce video core clock for encoding

    After performance and power analysis, video core clock
    should be reduced to 133MHz for 1080p@30fps load. With
    this clock setting, camcorder end to end performance is
    not impacted.

    Change-Id: Iee0fa9ce20181935faceb7b833b1aa510bbc6976
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit b717b9d6825305d55b3aff75545afbd283ee0714
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Sep 14 12:00:45 2012 -0700

    msm: vidc: Camcorder performance enhancement

    Set VBIF priority register to achieve 1080p @ 30fps
    camcorder performance. This register setting has been
    recommended after performance testing.

    Change-Id: I5feb128b0ff460f3638edb6ca644efbfb3b03283
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 071b9bef721194780cea699b31cdff7d19921052
Author: Mitchel Humpherys <mitchelh@codeaurora.org>
Date:   Thu Sep 6 10:45:28 2012 -0700

    msm: vidc: include msm-specific ion header

    All msm_ion clients need to use <linux/msm_ion.h> instead of
    <linux/ion.h>

    Change-Id: Ie44e862e13d0929b6ef6e73a74a7bb19a5c6319e
    Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

commit 4e042b585af2a84e5dec89aba56219dfcdebbec5
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed Sep 12 13:41:39 2012 -0700

    msm: vidc: Remove HAL_MSG_* macros

    Video driver no longer uses HAL_MSG_* macros
    for debug messages. Instead dprintk is uses.
    Removing these macros as they are deprecated.

    Change-Id: Id3949b28c1fcd85803c061768e59da79218171f0
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit aaeffd29ab225cd12f30c9dbd581b015ffaf2cab
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Tue Sep 11 17:19:55 2012 -0700

    msm: vidc: Reduce OCMEM bandwidth request.

    Reduce bandwidth request for OCMEM as same
    performance is achieved at lower bandwidth
    numbers.

    Change-Id: I2e1f1560681f86316ecccb08a9daabf46b70cf3e
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit e76323d5edd85dc16a21c1ebee2044f370292f14
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Sep 10 18:03:48 2012 -0700

    msm: vidc: Remove spinlock around ocmem_free

    Spinlock around OCMEM free is not needed. This
    is already being protected by a mutex.

    Change-Id: I9fa370047433812a6b267e24fb4a71ab5443ad58
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 934e81ed00866b905a5e6a8ce53fd45699173dea
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Mon Sep 10 16:56:45 2012 -0700

    msm_vidc: Fix bus bw request for lower resolutions

    Fix bus bw request for lower resolution and send
    proper device address to firmware while releasing
    buffers. With this change clips less than VGA
    resolution should work.

    Change-Id: I96f3ef4185f1ba88931f92a859c3fd92d6e13b63
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 15e870b358cbe8f9e75209448ef6a92f8e4793b3
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Sep 10 15:30:23 2012 -0700

    msm: vidc: Encoder performance tuning.

    Set VBIF registers and clock changes to improve
    encoder performance. This is required to achieve
    1080p 30fps encoding.

    Change-Id: Iacb66e70a3988ca114b23ff002aa46d0fbadeb54
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit b673450004ebe1e44748c1f414900b114d745cb1
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Fri Aug 24 13:00:22 2012 -0700

    msm_vidc: Changes to enable Camcorder

    - Add get_seq_hdr support in driver
    - send KEYFRMAE flag with first frame data

    Change-Id: I57c9097f3f54e63bb8e46629aed987cee054c816
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit f1a7cffbda1049a005ca7c028bfd305fc95f6760
Author: Blaine Dietrich <blained@codeaurora.org>
Date:   Mon Jul 23 12:14:18 2012 -0700

    msm: vidc: Enable/disbale debug messages

    Adds support to enable/disable debug messages
    from debugfs so that messages only upto a
    desired priority can be enabled. By default,
    only error messages are enabled.

    Change-Id: Id133c3f109d227862d1fa580f3b5df4cbbc37e11
    Signed-off-by: Blaine Dietrich <blained@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 7ceb94edc3f97df463b6e1c3e9062760fb7f9ad2
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed May 23 20:19:54 2012 -0700

    msm: vidc: Add debug support for video driver

    Add debugfs and other debug support for video
    codec driver. This creates a debugfs entry
    on device for video and basic information
    about video playback and encoding can be obtained
    from the debugfs files.

    Change-Id: Id4d3d7f6e38bb4993587621ecb8e5dc6bbeb00fd
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 4cd435dd3e4d0157c8d8a692ea66a39d826c3351
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Thu Aug 23 12:59:24 2012 -0700

    msm: vidc: Add flush for video codecs

    Add support to flush input/output buffers. This will flush
    the buffers being held by firmware or video driver and
    return them to client. This operation is usually used
    by an application during seek operation or while
    closing the driver.

    Change-Id: I61d3d8f94eeeeeea0e4c40460bebfd7873f428df
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 9f2303869d0d81b8e09a27e8c3fb2e5057d25dbb
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Fri Aug 24 11:48:41 2012 -0700

    msm: vidc: Pass on the CODECCONFIG flag to core

    In case of SPS/PPS buffers in frame by frame mode,
    the respective buffers must be marked with the
    CODECCONFIG flag.

    Change-Id: Iba29fc03ec736280f2babefc68d3380e856e3006
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit be3d0f7d01f715a642b87f602a2b97f9da6d23f5
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed Aug 29 21:10:53 2012 -0700

    msm: vidc: Reduce calls to get buffer requirements

    Reduce calls to firmware to get buffer requirements.
    This call is very expensive causing too much delay
    in video startup. Only calling this when necessary.

    Change-Id: I01f59b5402e82a79742f257d39cda1c9504e6dd0
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit d40bd3f22bec010057a7f26d43f0c8f84edd79fa
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Aug 31 13:22:32 2012 -0700

    msm: vidc: Tune input buffer count for performance

    With just two input buffers, video hardware stays
    idle quite often waiting for data. With the new
    input buffer count venus idle time is reduced and
    improved performance is observed.

    Change-Id: Ia44e106e4c8cf46ebcae9c89054508337c23a6cb
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit cdf8d0cf7bb1e8313d2e5f949ef00b59ef797553
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Tue Aug 28 12:07:36 2012 -0700

    msm: vidc: Video performance tuning.

    Setting vbif registers as per the performance
    analysis to achieve better video performance.

    Change-Id: Id12ebb93ea3bea6e599b40bebf16b0cab16a2bdf
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit a31f9e6ba2087844b3c124aa961463fc99ec95ab
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Aug 20 22:49:18 2012 -0700

    msm: vidc: Fix clock and bus scaling

    Fix bus and clock scaling requests by video
    encoder and decoder. Updated bus bandwidth
    numbers after performance analysis.

    Change-Id: I17a6e857679e88afb88a0b31e9e1a0f4da3d995d
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 20d2801618a3ec248fa0188f9494a91f0e29f4d5
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Thu Aug 23 14:07:10 2012 -0700

    msm: vidc: Always map into IOMMU as uncached

    If buffers provided by userspace are cached, mapping into IOMMU with the
    same flags results in a failiure as cached IOMMU mappings are not
    supported.  As a result, map all buffers as uncached.

    Change-Id: I483eab817b330e4aa7e232b30db2ae0d56730d8b
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 39a8e71631e6658e0909df3573b44694b0df0c96
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Fri Aug 17 16:39:51 2012 -0700

    msm: vidc: Return timestamps correctly back to the client

    Propagate the timestamp client provides on the OUTPUT port to the
    CAPTURE port.  Additionally, use kernel provided functions to convert
    the timeval struct to a 64 bit value rather than requiring the clients
    to set the timestamp within the tv_usec field.

    Change-Id: I19b8b953c837199019d7370f8bf3afec88a0d00d
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit cd111c7a4710f08ea28e4cdb17d6e6e088d38d60
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Aug 16 22:39:02 2012 -0700

    vidc: fix NV12 buffer size calculation in encoder and decoder.

    Buffer size calculation in driver and firmware is different. This
    results in inconsistent behaviour for different resolutions. This
    change calculates buffer size as in firmware.

    Change-Id: I9dca9e0e8729eb4e578de63dc43c01dd65c3f3be
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 3dbe9997ba80f8fcd7e90a91c8dc8154a991ff07
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Mon Aug 20 12:22:57 2012 -0700

    msm_vidc: Fix setting queue size to firmware.

    Incorrect queue size was being set to firmware. This patch fixes the issue.

    Change-Id: Ic0ab9384d364f70cf06c352331887dfcdf6592c4
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 3475a6e57c17051ffe2180f02f38957e36a912c0
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Fri Aug 10 21:34:03 2012 -0700

    msm: vidc: Honor client's request for more buffers

    The driver should allow the client's request for more buffers than the
    minimum rather than enforcing just the minimum required by Venus.

    Change-Id: I8c10372b1ffef55d0e73b824b13ad80de2446f23
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit 564814bd20e01d1d49a105df00604ab90b418179
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Aug 20 11:09:57 2012 -0700

    msm: vidc: Fix for IOMMU mapping.

    Same memory region was being mapped multiple times.
    This fix avoids this scenario and makes sure that
    that we map proper size and single fd is mapped
    and unmapped one time only.

    Change-Id: Ibba932456792d5964213fe93db2c6101ad94b74c
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit e38c55f7034c140d6bdd57bc7016107e3746e72f
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Thu Aug 16 19:37:28 2012 -0700

    msm: vidc: Add support for cached ion allocation

    Add support to allocate ion memory from cached
    or uncached region in video driver. Also, Clean and
    invalidate caches for input, output, shared command
    memory and internal buffers incase they are allocated
    from cached region.

    Change-Id: Id1ac9587bfef8d2d0e2a3d3d30f30e39de10665e
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 8383c095459de560e644c7fa1f96dd8dcc025983
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Aug 16 22:30:09 2012 -0700

    vidc: Disable venus VBIF dynamic clock gating for video core.

    Video core behaviour was inconsistent for different resolutions. This
    was due to dynamic clock gating for venus VBIF was enabled. Disable Venus
    VBIF clock gating to prevent this inconsistent behaviour.

    Change-Id: Id7efd4b7f922efcb77c729f1dc119b1549cb8d74
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit cbad85b92cfe6e487c1da0c723f3e94206690a0c
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Fri Aug 17 14:38:53 2012 -0700

    vidc: Use correct port setting for encoder during prepare buffer.

    When prepare buffer was called for encoder, the port configurations
    were swapped. This change corrects this error.

    Change-Id: I927cf66666dd02e0f4abbdc9d7be561a857ab2b0
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit c71662f18efbbd44270df8c81571c73ea98a980a
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Thu Aug 16 17:49:28 2012 -0700

    msm: vidc: Separate partition for shared memory

    Create separate partition for shared command
    queues. Virtual device addresses for shared
    command queues need to be from upper 16MB
    region of mon-secure virtual device address
    space. This change creates a partition to
    ensure this.

    Change-Id: Iba22daf93b7d08c70f43685de7182a2f235a7690
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 443e6348f76663fd0d590c3fe446ec3fda838854
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Mon Jul 30 00:48:07 2012 -0700

    msm:  vidc: Adds support for Rate Control

    Adds support for Rate Control by setting correct
    RC Mode and bit rate.

    Change-Id: I0307417f3a517e0aa40f67c5d4835db3ef4ea444
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit e541526f3b35b02b25831c14cbc4f43baf6310df
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Wed Aug 1 16:21:08 2012 -0700

    msm: vidc: Adds support to send new command

    - Adds supports to send DECODER command to
    decoder which inturn used to CLOSE the instance.
    - Adds supports to send ENCODER command to
    encoder which inturn used to CLOSE the instance.

    Change-Id: Ia6037fdf66824538124f775442150b7a4ed201b8
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit cd9383f390ebce77c88cd6acb1345fee5b0a497b
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Thu Aug 2 15:58:26 2012 -0700

    msm: vidc: Adds support to send frame rate to Video Hardware

    Adds support to send frame rate to Video HW in right format.

    Change-Id: Ifba83310cb88e6ec898266f9d24bb157ae63aad6
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit d075233da173e5ea1e64f7558d3b3fc8f8a74e4a
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Jul 6 11:14:21 2012 -0700

    msm: vidc: Adds error check for controls

    - Adds Error check before calling control to make
    sure that Venus is in right state.
    - Adds supports to calculate right scratch buffer length.

    Change-Id: I83043a87859d7bb31c683e3ad19a4a23fb519747
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit d39507a2afd46a2caa4460699a72d0ee1287c687
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Jul 30 17:31:37 2012 -0700

    msm: vidc: Allocate persist buffers.

    Persist buffers are needed by decoder/encoder
    in some cases. These buffers are mandatory and
    cannot be ignored. This change allocates persist
    buffers according to the requirement by video device
    to avoid hangs.

    Change-Id: I961bb1abe45dba1cbc770edef2277f33ea186546
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit c2a557ca7c83963156770f6e4212619969c29714
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Aug 3 11:39:47 2012 -0700

    msm: vidc: Fix scratch buffer allocation.

    In some cases, firmware is reqesting driver
    to allocate one scratch with size zero,
    eg: if height and width is set to zero on
    firmware. This change handles this scenario
    appropriately to avoid kernel panic.

    Change-Id: If670f91ef600678af8e246934f685defcb7fdfeb
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 12d8eefc7bcdb1dc4f65b0943e8ea1f1e8b9ea31
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Aug 3 17:45:53 2012 -0700

    msm: vidc: Set proper height and width.

    Set proper height and width on firmware.
    Proper height, width was not getting set
    on firmware resulting in firmware reporting
    bad buffer requirements which caused hang or
    crash during port reconfig.

    Change-Id: I4097e0219a1df423fdd0ec9421800635525cf8c4
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit b17f8aa08ff5d4c7acff0dd3f07019f1755be7b6
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Mon Jul 30 17:16:32 2012 -0700

    msm: vidc: Specify the number of planes in buffer to client

    When a V4L2 client sets or gets the format, driver is supposed to report
    back the dimensions, the size of the buffer, and the number of planes
    contained with in the buffer.  The former two were being reported back
    to the client, while the latter wasn't.

    Change-Id: Ie225e108ce90cc40823ee9c0f13aeb7d054f5bdb
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit bc9f60a99f7d6130e6d8028e340a421072498d3f
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Tue Jul 17 01:23:42 2012 -0700

    msm: vidc: Uses on-chip memory for video codecs

    Video driver allocates on-chip memory (OCMEM) and
    hands it over to the video hardware for internal usage.
    Video encode/decode performance improves with OCMEM.

    Change-Id: Ic6e35278db24cedc003aa33d5e3cef52172e2254
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit cb722d6f8f9a27cd9d579bc8821692b6b03beefc
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Thu Jun 28 19:35:22 2012 -0700

    msm: vidc: Adds bus scaling for video codecs

    Adds bus scaling so that the bus bandwidth
    can be voted for according to load. This
    optimizes power consumption during video
    encode and decode operation.

    Change-Id: I4b7123e9ae2e429ffe9bf4636d633284768e1b33
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 6a8d04ce4f9fa9b7ea96a7009120c9bcee295627
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Tue Jul 17 19:23:05 2012 -0700

    msm: vidc: Change configuration flag for video.

    Change kernel configuration flag for video
    on 8974 so that it does not interfere with
    video drivers on other chipsets.

    Change-Id: I74fa8f0ed7be713893b9e280bb9b77606bc5c786
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 94b221b88d8274f1d04839e52ad3b09fc5aa5fe1
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Jun 25 18:50:13 2012 -0700

    msm: vidc: Adds clock scaling

    Video driver manages clock rate according
    to the increase in load on video core. Clock
    is scaled as per number of macroblocks
    decoded/encoded per second. This makes sure
    that the power consumption and performance is
    optimal.

    Change-Id: If8aede0e3048cdc9bcdf14ce0c239a58bdd5d263
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 0ebb19b6f630f7ee2338504b37db278b617d2a5e
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Fri Jun 22 01:32:37 2012 -0700

    msm: vidc: Add controls specific to H263

    Userspace requires controls to set profile and level values. Hence
    expose V4L2_CID_MPEG_VIDC_VIDEO_H263_PROFILE and
    V4L2_CID_MPEG_VIDC_VIDEO_H263_LEVEL.

    Change-Id: Id2b5d4ade8dda1a32b11820936532300b18c37ac
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 68398a4f0e87aa7285ccf55d1e087f15c32aedca
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Jun 22 18:36:12 2012 -0700

    msm: vidc: Download firmware using PIL.

    Video driver uses PIL and IOMMU to download video
    firmware.Video firmware is downloaded during the
    start of video session using PIL apis.

    Change-Id: If285e9b6df57ecdfa379fa82b9eef542e6aa9bba
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 9c4d9599ad8d57a4fa860c52ac892441a5e605bc
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Sat Jul 14 01:27:35 2012 -0700

    msm: vidc: Adds support for high bit rate and frame rate

    Increased the maximum value for controls
    V4L2_CID_MPEG_VIDEO_BITRATE and
    V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE thus by
    increasing maximum supported frame rate and bit rate.

    Change-Id: I6330d178d12652683cce793b7544572594b5dabf
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 951c02de0409e5e56ce2cfe0c06989e2aec1814a
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Wed Jul 11 12:19:42 2012 -0700

    msm: vidc: Adds support for dynamic I frame request.

    Adds support for dynamic Intra frame request by setting
    correct command packet size to video hardware.

    Change-Id: Id851345176bfececae87927fcd61cc9e3f028828
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit c5041daa75ffab4ce8cffb222298bd958fec5ffe
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Wed Jul 18 15:44:57 2012 -0700

    msm: vidc: Adds support for high bit rate decode

    Adds support for high bit rate decoding by
    increasing the input buffer size to hold
    large input frame data.

    Change-Id: I06f8bebddf879104761956bd982c44d854edca2b
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit a46f06badbe9da62bb64790d45c34293b3831a00
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Jul 6 12:23:48 2012 -0700

    msm: vidc: Adds support for VP8 Encoder.

    Adds support for VP8 video encoder by adding VP8
    entry in venc formats struct.

    Change-Id: Icb9fbc049aadd226c7f803ad938d1d76cbb760f4
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 40c3ae806210f2e4576e8fa44fb871124a8fbcc7
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Jul 9 15:23:02 2012 -0700

    msm: vidc: Fixes back-to-back video decode/encode.

    Fixes a bug introduced in recent commit because of
    which only one video session worked. Next video
    session always failed when client tries to open
    the video device.

    The commit ID caused the issue is
    fe72c45cf670cb0fafb04a6a2fa6a1aa428435c6

    Change-Id: Ib0cbe7cac5189cf617e8b3bcfc549e022e88fd46
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 1e8ddaef241c09ab7684fd6dea4a7952c3d57e42
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Jul 6 12:13:06 2012 -0700

    msm: vidc: Adds support for VP8 Decoder.

    Adds support for VP8 Decoder by adding VP8 codec
    entry in vdec formats struct.

    Change-Id: I93bca63e18ae2ba2a125e76584d230c0af1cc33a
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit df7532d69948f453d66f59d0303fe116e3ad8919
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Mon Jul 9 11:21:16 2012 -0700

    msm: vidc: Migration to new firmware version.

    Adds support for the new firmware version by incorporating
    the interface changes between driver and video firmware.
    These changes make the driver compatible to new firmware
    version.

    FW_VERSION: 100100

    Change-Id: I04e9457ac8a85a070f2e4c738ad3e4fc9cbfbaeb
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 1b03554c22ee7d6a90f1a281072dbb73ee831535
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Jul 6 11:02:38 2012 -0700

    msm: vidc: Adds support to send individual controls.

    Adds support to set individual properties to Venus by
    calling controls separately.

    Change-Id: I4af3176ee009f202e62d566de3ce859b6a8d36c2
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit b040a018b5ec2f054e58b6a3b2806c161fd9d22a
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Jul 6 11:29:15 2012 -0700

    msm: vidc: Adds support for Intra Refresh

    Adds Support for Intra refresh by setting
    default values and calling right set_property.

    Change-Id: Ibc04ec195b5265a1db60befb8109693a41f8fe51
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit d8c98c33c58f5f78e7fb60a678fac69b33424dc0
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Fri Jun 15 18:32:52 2012 -0700

    msm: vidc: Fixes polling on video driver.

    poll should return all the available events
    in one call. This change implements this
    behavior.

    Change-Id: I498b621cc5d8fca820376109ca4a5f1bd4c492b2
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 2bf4fb12fdfbfe5552039c6d9d272fdd0c95937c
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Wed Jun 27 20:42:33 2012 -0700

    msm: vidc: Amend buffer size calculation

    Amend the input and output buffer calculation to
    reflect what the Venus core expects.

    Change-Id: Ib3c600d0e838525e3a82a1b2c05803f86075ba15
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit 98dfb65a7644809b8868809262a8fbf4937aa915
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Jul 6 08:19:37 2012 -0700

    msm: vidc: Adds support to parse SEQ_CHANGED cmd payload

    Adds support to parse the payload of command
    evt_seq_changed to know about resource request.

    Change-Id: I483954b0453a84be26e3d180f4f18bef042ab409
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 3a323802585b92a821aa79e368611d7c0cb407b3
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Fri Jun 15 15:15:42 2012 -0700

    msm: vidc: Add input buffer flushing support

    Flushing the core is now done with the V4L2_DEC_QCOM_CMD_FLUSH ioctl
    rather than V4L2_DEC_CMD_STOP.  The latter is confusing and the
    arguments specified by the V4L2 spec do not allow for flushing the input
    and and output buffers seperately.

    Change-Id: I53e18e06c4e09ee8496bdcc337b4798f22911708
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit 1fc82a278c42f755e65dc909baf2326a3a6e142e
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Jul 6 11:38:51 2012 -0700

    msm: vidc: Adds Profile and Level support

    Adds support for Profile and Level support by setting
    default values and calling set_property.

    Change-Id: Ied289779bca6441c5cfdde7c766c02c14c8bce23
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit e29238b519a7c3b210ceab89029baf0498f6328d
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Fri Jul 6 12:04:17 2012 -0700

    msm: vidc: Adds support for VC-1 decoder

    Adds support for VC-1 decoder by adding the VC-1 Decoder
    entry in vdec formats struct.

    Change-Id: I4a5a278a93c252f4e3a16eb004d06d72dba6e491
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit b361d7772dffe94636c53ea0da113cfc6637fab7
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Thu Jul 5 23:26:55 2012 -0700

    msm: vidc: Adds new event type

    Adds new event type to convey about the resources
    requirement.

    Change-Id: I7ea67231c247dc983463a02b828c10adc486b60d
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit b14ed96f74b1258b1f102831a2b0ccd56f991132
Author: Laura Abbott <lauraa@codeaurora.org>
Date:   Mon Jan 30 14:18:08 2012 -0800

    gpu: ion: Pull in patches for 3.4

    Pull in Ion patches for 3.4 upgrade. Inclues the following
    patches from google:

     commit 7191e9ba25
     Author: Rebecca Schultz Zavin <rebecca@android.com>
     Date:   Mon Jan 30 14:18:08 2012 -0800

         ion: Switch map/unmap dma api to sg_tables

         Switch these api's from scatterlists to sg_tables

         Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>

     commit 6f9e56945d
     Author: Rebecca Schultz Zavin <rebecca@android.com>
     Date:   Tue Jan 31 09:40:30 2012 -0800

         ion: Add reserve function to ion

         Rather than requiring each platform call memblock_remove or reserve
         from the board file, add this to ion

         Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>

     commit 9ae7e01de1
     Author: KyongHo Cho <pullip.cho@samsung.com>
     Date:   Wed Sep 7 11:27:07 2011 +0900

         gpu: ion: several bugfixes and enhancements of ION

         1. Verifying if the size of memory allocation in ion_alloc() is aligned
         by PAGE_SIZE at least. If it is not, this change makes the size to be
         aligned by PAGE_SIZE.

         2. Unmaps all mappings to the kernel and DMA address spaces when
         destroying ion_buffer in ion_buffer_destroy(). This prevents leaks in
         those virtual address spaces.

         3. Makes the return value of ion_alloc() to be explicit Linux error code
         when it fails to allocate a buffer.

         4. Makes ion_alloc() implementation simpler. Removes 'goto' statement and
         relavant call to ion_buffer_put().

         5. Checks if the task is valid before calling put_task_struct() due
         to failure on creating a ion client in ion_client_create().

         6. Returns error when buffer allocation requested by userspace is failed.

         Signed-off-by: KyongHo Cho <pullip.cho@samsung.com>

     commit 043a61468f
     Author: Rebecca Schultz Zavin <rebecca@android.com>
     Date:   Wed Feb 1 11:09:46 2012 -0800

         ion: Switch ion to use dma-buf

         Ion now uses dma-buf file descriptors to share
         buffers with userspace.  Ion becomes a dma-buf
         exporter and any driver that can import dma-bufs
         can now import ion file descriptors.

         Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>

     commit 0d1259b5f8
     Author: Rebecca Schultz Zavin <rebecca@android.com>
     Date:   Mon Apr 30 16:45:38 2012 -0700

         gpu: ion: Use alloc_pages instead of vmalloc from the system heap

         With this change the ion_system_heap will only use kernel address
         space when the memory is mapped into the kernel (rare case).

         Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>

     commit be4a1ee79a
     Author: Rebecca Schultz Zavin <rebecca@android.com>
     Date:   Thu Apr 26 20:44:10 2012 -0700

         gpu: ion: support begin/end and kmap/kunmap dma_buf ops

         These ops were added in the 3.4 kernel.  This patch adds support
         for them to ion.  Previous ion_map/unmap_kernel api is also
         retained in addition to this new api.

         Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>

     commit 46d71337f9
     Author: Rebecca Schultz Zavin <rebecca@android.com>
     Date:   Mon May 7 16:06:32 2012 -0700

         gpu: ion: Allocate the sg_table at creation time rather than dynamically

         Rather than calling map_dma on the allocations dynamically, this patch
         switches to creating the sg_table at the time the buffer is created.
         This is necessary because in future updates the sg_table will be used
         for cache maintenance.

         Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>

     commit 903f6c716d
     Author: Rebecca Schultz Zavin <rebecca@android.com>
     Date:   Wed May 23 12:55:55 2012 -0700

         gpu: ion: Get an sg_table from an ion handle

         This patch adds an interface to return and sg_table given a
         valid ion handle.

         Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>

    The commit also includes fixups needed for MSM specific code.

    Change-Id: Idbcfa9d6af0febf06f56daaa6beaa59cc08e4351
    Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

commit 995fd27825c1bb27f0bfa76d4a887dc00cd0f1eb
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Mon Jul 2 12:57:55 2012 -0700

    msm_vidc: Fix decoder output order.

    Decoder's output order was configured incorrectly, this
    change fixes it.

    Change-Id: I523260db33f1df5ffb7c30026683b272c9a05488
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 90ced6e40066e6ed681b78d1689ef9b8e552f0ab
Author: Abhimanyu Kapur <abhimany@codeaurora.org>
Date:   Tue Jun 26 17:41:25 2012 -0700

    msm: 8974: rename copper to 8974

    The official name for copper is MSM8974.
    Switch to it.

    Change-Id: Ifb241232111139912477bf7b5f2e9cf5d38d0f9e
    Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>

commit fe72c45cf670cb0fafb04a6a2fa6a1aa428435c6
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Tue May 29 19:52:00 2012 -0700

    vidc_hal: update driver to new hal interface.

    Update video driver to maintain video functionality with
    new hardware interface.

    Change-Id: I731133ffc4b3633d0c2b55846d983846dfe6930f
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit cf7e27f92a99cdc422d67f6d328c0b910d2bbf9d
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Thu Jun 14 19:05:15 2012 -0700

    msm: vidc: Video driver update to kernel 3.4.

    During the migration from kernel 3.0 to 3.4, V4L2 framework changed.
    This requires changes from video driver. This change makes video
    driver code compatible with kernel 3.4.

    Change-Id: I12fb28e4b7c261c9755fbb62bb6bb8ea299d5272
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit 1c72b395348a0d4944e4f05e2979c80e7f8d8c52
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Wed Jun 20 10:50:00 2012 -0700

    msm: video: Fix compiler warnings

    changed array definitions, #defines and variable repetition to resolve
    warnings in compilation.

    Change-Id: Ic26f1924da389f4a8638728963c6a4c8b2f859d0
    Signed-off-by: Jessica Gonzalez <jgaona@codeaurora.org>

commit 240368102e7f6f23ed70835c97bb4e43effb78cc
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Thu Jun 14 00:26:25 2012 -0700

    msm: media: Adds error check in memory alloc function

    Adds Error check for Zero size.

    Change-Id: Ib450c1c8b34436b6a5d1fdc3c14dbb52c9b3f177
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit a1980a18e0e6f868485b232af83efb58f2b3f004
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Thu May 31 12:31:10 2012 -0700

    msm: vidc: Add support for DIVX 4/5/6

    Add support to the driver to properly configure the Venus core for
    various DIVX formats.

    Change-Id: Ica6411936a09edfc3aa4ca321c781ff22948742a
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit c249b751531d3ca2f5506d083720571cb07fc453
Author: Deva Ramasubramanian <dramasub@codeaurora.org>
Date:   Fri May 18 17:31:03 2012 -0700

    msm: vidc: Add DIVX311 support

    Implement changes in the driver to support decoding of Divx311
    bitstreams

    Change-Id: Ie4e05c9161d89b866f9f36ca1865a9b64bc51240
    Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>

commit e6a37af67ac6f2f9eef441e57d13914b4682e1ef
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed May 16 16:47:54 2012 -0700

    msm: vidc: Removes extradata allocation.

    Reverting extradata allocation added earlier in
    3766b1e6b4dea7dea0abed1e9090390640a12909 because
    extradata allocation is causing a hang in firmware.

    Change-Id: I18854cf19757a01794522da75f066bf1ff5e0aa0
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

commit bff3d1085ec9aeb7942fe76ea3520741061eb1cc
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Mon May 21 14:50:27 2012 -0700

    media: msm_vidc: change encoder output size

    Change encoder buffer size from fixed to resolution based,
    so high resolution input can be encoded

    Change-Id: I572c8c82a649ae11abe1319bb13d24838d6fcfd1
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit cb00cab7f826f54338303bbb8f02ce72cfa05030
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Mon May 21 14:22:55 2012 -0700

    media: msm_vidc: extradata buffer cleanup.

    move extradata buffer cleanup to the end of decoder session to
    enable back to back decoding

    Change-Id: Ib4183c73d083efc26442d42e33dc9e2d476ecc13
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit f2acb8593e9b17c69a4c33dd280ecd7edee3dbea
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Mon May 7 17:44:53 2012 -0700

    msm: vidc: Adds support for port reconfiguration.

    Adds support for port reconfiguration. This enables decoder to
    reconfigure to new resolution or settings other than initially
    configured to continue video playback.

    Change-Id: Id11e973e4cf1a5c7e4ec5544215fe57cb19466be
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit 5b79a3252710683b406c03ab21a808e852cb2962
Author: Praneeth Paladugu <ppaladug@codeaurora.org>
Date:   Wed Apr 18 15:16:29 2012 -0700

    msm: vidc: Adds support for conveying events.

    Adds support for conveying events to userspace from kernel
    driver. This is needed to let userspace/client know of
    any error or other event of importance.

    Change-Id: Ife450b9f5dfe23f07b6f346c8e27c214fc85e083
    Signed-off-by: Praneeth Paladugu <ppaladug@codeaurora.org>

commit a6b8db6c28d6db6409bba8397b28f4b89dfb74ac
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Fri Apr 20 15:20:29 2012 -0700

    msm: msm_vidc: enable msm_vidc driver compilation on 8x74.

    Enables compilation of v4l2 based video driver for 8x74.V4L2 clients
    can use video driver to encode and decode video using hardware
    accelerated codecs.

    Change-Id: If615930ddf72023b2a626af6cca87ebf56ede047
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 9c8bab95ac974600c7809db2fc7b3c35004fd5dd
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu May 17 18:20:25 2012 -0700

    media: msm_vidc: fix compilation issue.

    This file depends on vidc_hal_api.h, which was modified to
    address review comments. The change reflects the fix.

    Change-Id: I2b5a64c28e87f6a1696f86c07d597fc058927e6c
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit d2ab0e33cf250647cccabff1073f736f05c7ee83
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Tue Apr 3 18:40:29 2012 -0700

    media: msm_vidc: add v4l2 controls for video encoder

    Adds encoder specific v4l2 controls in video driver, giving
    flexibility to userspace or in-kernel v4l2 client to change/set
    video encoder properties like  codec, profile, level, resolution,
    bitrate, ratecontrol, framerate to video hardware.

    Change-Id: Ie9d0eed301c3adad20471d8ef93f8087fe9dda15
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 1ccbc9106c61b27462036667e7896bdbe0c7d8fb
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Fri Mar 23 16:26:52 2012 -0700

    media: msm_vidc: add set property support in video driver

    Enables setting video encoding and decoding parameters to video
    hardware. This allows configuring video hardware with userspace
    or in-kernel client settings for codec, profile, level, bitrate,
    resolution, ratecontrol, framerate.

    Change-Id: Ie95674dc4ad50e00d737e765af1382c1397d4442
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 6ab782bdf6385bb325667841b7ee53a62a97dca5
Author: Ashray Kulkarni <ashrayk@codeaurora.org>
Date:   Thu Jan 26 16:58:01 2012 -0800

    media: msm_vidc: Add hardware interface for video core.

    - Provides hardware level interface to perform video encoding
      and decoding.
    - Implements interrupt handling and processing for video core.
    - Packages data to core readable format and processes response from core.

    Change-Id: Ie16796449d2aacf331c7e02b3f0a63175cc5d37b
    Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>

commit 3766b1e6b4dea7dea0abed1e9090390640a12909
Author: Vinay Kalia <vkalia@codeaurora.org>
Date:   Wed Jan 11 18:58:41 2012 -0800

    media: msm_vidc: Add video driver for video core.

    - Adds video encoding and decoding functionality.
    - Implements v4l2 interface based driver for interacting
      with userspace modules to perform video encoding and
      decoding.
    - Implements kernel API for interacting with kernel
      modules like Wifi display(encoder) and V4L2 based
      DVB(decoder).

    Change-Id: Iadb83b60139e659ae7f66e5dc38c46fef52ca99d
    Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>

Signed-off-by: David Brown <davidb@codeaurora.org>
This commit is contained in:
David Brown
2013-01-14 14:02:57 -08:00
committed by Stephen Boyd
parent 96bb55d8ff
commit cf5a4992bf
22 changed files with 10257 additions and 0 deletions

View File

@@ -1246,3 +1246,5 @@ config VIDEO_MX2_EMMAPRP
conversion.
endif # V4L_MEM2MEM_DRIVERS
source "drivers/media/video/msm_vidc/Kconfig"

View File

@@ -210,6 +210,7 @@ obj-y += davinci/
obj-$(CONFIG_MSM_CAMERA) += msm/
obj-$(CONFIG_ARCH_OMAP) += omap/
obj-$(CONFIG_MSM_VIDC) += msm_vidc/
ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
ccflags-y += -I$(srctree)/drivers/media/dvb/frontends

View File

@@ -0,0 +1,8 @@
#
# VIDEO CORE
#
menuconfig MSM_VIDC
bool "Qualcomm MSM Video Core Driver"
depends on ARCH_MSMCOPPER && VIDEO_V4L2
default y

View File

@@ -0,0 +1,8 @@
obj-$(CONFIG_MSM_VIDC) := msm_v4l2_vidc.o \
msm_vidc_common.o \
msm_vidc.o \
msm_vdec.o \
msm_venc.o \
msm_smem.o \
vidc_hal.o \
vidc_hal_interrupt_handler.o \

View File

@@ -0,0 +1,244 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/slab.h>
#include "msm_smem.h"
struct smem_client {
int mem_type;
void *clnt;
};
static int ion_user_to_kernel(struct smem_client *client,
int fd, u32 offset, struct msm_smem *mem)
{
struct ion_handle *hndl;
unsigned long ionflag;
size_t len;
int rc = 0;
hndl = ion_import_fd(client->clnt, fd);
if (IS_ERR_OR_NULL(hndl)) {
pr_err("Failed to get handle: %p, %d, %d, %p\n",
client, fd, offset, hndl);
rc = -ENOMEM;
goto fail_import_fd;
}
rc = ion_handle_get_flags(client->clnt, hndl, &ionflag);
if (rc) {
pr_err("Failed to get ion flags: %d", rc);
goto fail_map;
}
rc = ion_phys(client->clnt, hndl, &mem->paddr, &len);
if (rc) {
pr_err("Failed to get physical address\n");
goto fail_map;
}
mem->kvaddr = ion_map_kernel(client->clnt, hndl, ionflag);
if (!mem->kvaddr) {
pr_err("Failed to map shared mem in kernel\n");
rc = -EIO;
goto fail_map;
}
mem->kvaddr += offset;
mem->paddr += offset;
mem->mem_type = client->mem_type;
mem->smem_priv = hndl;
mem->device_addr = mem->paddr;
mem->size = len;
return rc;
fail_map:
ion_free(client->clnt, hndl);
fail_import_fd:
return rc;
}
static int alloc_ion_mem(struct smem_client *client, size_t size,
u32 align, u32 flags, struct msm_smem *mem)
{
struct ion_handle *hndl;
size_t len;
int rc = 0;
flags = flags | ION_HEAP(ION_CP_MM_HEAP_ID);
hndl = ion_alloc(client->clnt, size, align, flags);
if (IS_ERR_OR_NULL(hndl)) {
pr_err("Failed to allocate shared memory = %p, %d, %d, 0x%x\n",
client, size, align, flags);
rc = -ENOMEM;
goto fail_shared_mem_alloc;
}
mem->mem_type = client->mem_type;
mem->smem_priv = hndl;
if (ion_phys(client->clnt, hndl, &mem->paddr, &len)) {
pr_err("Failed to get physical address\n");
rc = -EIO;
goto fail_map;
}
mem->device_addr = mem->paddr;
mem->size = size;
mem->kvaddr = ion_map_kernel(client->clnt, hndl, 0);
if (!mem->kvaddr) {
pr_err("Failed to map shared mem in kernel\n");
rc = -EIO;
goto fail_map;
}
return rc;
fail_map:
ion_free(client->clnt, hndl);
fail_shared_mem_alloc:
return rc;
}
static void free_ion_mem(struct smem_client *client, struct msm_smem *mem)
{
ion_unmap_kernel(client->clnt, mem->smem_priv);
ion_free(client->clnt, mem->smem_priv);
}
static void *ion_new_client(void)
{
struct ion_client *client = NULL;
client = msm_ion_client_create(-1, "video_client");
if (!client)
pr_err("Failed to create smem client\n");
return client;
};
static void ion_delete_client(struct smem_client *client)
{
ion_client_destroy(client->clnt);
}
struct msm_smem *msm_smem_user_to_kernel(void *clt, int fd, u32 offset)
{
struct smem_client *client = clt;
int rc = 0;
struct msm_smem *mem;
if (fd < 0) {
pr_err("Invalid fd: %d\n", fd);
return NULL;
}
mem = kzalloc(sizeof(*mem), GFP_KERNEL);
if (!mem) {
pr_err("Failed to allocte shared mem\n");
return NULL;
}
switch (client->mem_type) {
case SMEM_ION:
rc = ion_user_to_kernel(clt, fd, offset, mem);
break;
default:
pr_err("Mem type not supported\n");
rc = -EINVAL;
break;
}
if (rc) {
pr_err("Failed to allocate shared memory\n");
kfree(mem);
mem = NULL;
}
return mem;
}
void *msm_smem_new_client(enum smem_type mtype)
{
struct smem_client *client = NULL;
void *clnt = NULL;
switch (mtype) {
case SMEM_ION:
clnt = ion_new_client();
break;
default:
pr_err("Mem type not supported\n");
break;
}
if (clnt) {
client = kzalloc(sizeof(*client), GFP_KERNEL);
if (client) {
client->mem_type = mtype;
client->clnt = clnt;
}
} else {
pr_err("Failed to create new client: mtype = %d\n", mtype);
}
return client;
};
struct msm_smem *msm_smem_alloc(void *clt, size_t size, u32 align, u32 flags)
{
struct smem_client *client;
int rc = 0;
struct msm_smem *mem;
client = clt;
if (!client) {
pr_err("Invalid client passed\n");
return NULL;
}
mem = kzalloc(sizeof(*mem), GFP_KERNEL);
if (!mem) {
pr_err("Failed to allocate shared mem\n");
return NULL;
}
switch (client->mem_type) {
case SMEM_ION:
rc = alloc_ion_mem(client, size, align, flags, mem);
break;
default:
pr_err("Mem type not supported\n");
rc = -EINVAL;
break;
}
if (rc) {
pr_err("Failed to allocate shared memory\n");
kfree(mem);
mem = NULL;
}
return mem;
}
void msm_smem_free(void *clt, struct msm_smem *mem)
{
struct smem_client *client = clt;
if (!client || !mem) {
pr_err("Invalid client/handle passed\n");
return;
}
switch (client->mem_type) {
case SMEM_ION:
free_ion_mem(client, mem);
break;
default:
pr_err("Mem type not supported\n");
break;
}
kfree(mem);
};
void msm_smem_delete_client(void *clt)
{
struct smem_client *client = clt;
if (!client) {
pr_err("Invalid client passed\n");
return;
}
switch (client->mem_type) {
case SMEM_ION:
ion_delete_client(client);
break;
default:
pr_err("Mem type not supported\n");
break;
}
kfree(client);
}

View File

@@ -0,0 +1,38 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _MSM_SMEM_H_
#define _MSM_SMEM_H_
#include <linux/types.h>
#include <linux/ion.h>
enum smem_type {
SMEM_ION,
};
struct msm_smem {
int mem_type;
size_t size;
void *kvaddr;
unsigned long paddr;
unsigned long device_addr;
/*Device address and others to follow*/
void *smem_priv;
};
void *msm_smem_new_client(enum smem_type mtype);
struct msm_smem *msm_smem_alloc(void *clt, size_t size, u32 align, u32 flags);
void msm_smem_free(void *clt, struct msm_smem *mem);
void msm_smem_delete_client(void *clt);
struct msm_smem *msm_smem_user_to_kernel(void *clt, int fd, u32 offset);
#endif

View File

@@ -0,0 +1,604 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/list.h>
#include <linux/ioctl.h>
#include <linux/spinlock.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/debugfs.h>
#include <linux/version.h>
#include <linux/slab.h>
#include <media/msm_vidc.h>
#include "msm_vidc_internal.h"
#include "vidc_hal_api.h"
#include "msm_smem.h"
#define BASE_DEVICE_NUMBER 32
struct msm_vidc_drv *vidc_driver;
struct buffer_info {
struct list_head list;
int type;
int fd;
int buff_off;
int size;
u32 uvaddr;
struct msm_smem *handle;
};
struct msm_v4l2_vid_inst {
struct msm_vidc_inst vidc_inst;
void *mem_client;
struct list_head registered_bufs;
};
static inline struct msm_vidc_inst *get_vidc_inst(struct file *filp, void *fh)
{
return container_of(filp->private_data,
struct msm_vidc_inst, event_handler);
}
static inline struct msm_v4l2_vid_inst *get_v4l2_inst(struct file *filp,
void *fh)
{
struct msm_vidc_inst *vidc_inst;
vidc_inst = container_of(filp->private_data,
struct msm_vidc_inst, event_handler);
return container_of((void *)vidc_inst,
struct msm_v4l2_vid_inst, vidc_inst);
}
static int msm_vidc_v4l2_setup_event_queue(void *inst,
struct video_device *pvdev)
{
int rc = 0;
struct msm_vidc_inst *vidc_inst = (struct msm_vidc_inst *)inst;
spin_lock_init(&pvdev->fh_lock);
INIT_LIST_HEAD(&pvdev->fh_list);
v4l2_fh_init(&vidc_inst->event_handler, pvdev);
v4l2_fh_add(&vidc_inst->event_handler);
return rc;
}
struct buffer_info *get_registered_buf(struct list_head *list,
int fd, u32 buff_off, u32 size)
{
struct buffer_info *temp;
struct buffer_info *ret = NULL;
if (!list || fd < 0) {
pr_err("%s Invalid input\n", __func__);
goto err_invalid_input;
}
if (!list_empty(list)) {
list_for_each_entry(temp, list, list) {
if (temp && temp->fd == fd &&
(CONTAINS(temp->buff_off, temp->size, buff_off)
|| CONTAINS(buff_off, size, temp->buff_off)
|| OVERLAPS(buff_off, size,
temp->buff_off, temp->size))) {
pr_err("This memory region is already mapped\n");
ret = temp;
break;
}
}
}
err_invalid_input:
return ret;
}
static int msm_v4l2_open(struct file *filp)
{
int rc = 0;
struct video_device *vdev = video_devdata(filp);
struct msm_video_device *vid_dev =
container_of(vdev, struct msm_video_device, vdev);
struct msm_vidc_core *core = video_drvdata(filp);
struct msm_v4l2_vid_inst *v4l2_inst = kzalloc(sizeof(*v4l2_inst),
GFP_KERNEL);
if (!v4l2_inst) {
pr_err("Failed to allocate memory for this instance\n");
rc = -ENOMEM;
goto fail_nomem;
}
v4l2_inst->mem_client = msm_smem_new_client(SMEM_ION);
if (!v4l2_inst->mem_client) {
pr_err("Failed to create memory client\n");
rc = -ENOMEM;
goto fail_mem_client;
}
rc = msm_vidc_open(&v4l2_inst->vidc_inst, core->id, vid_dev->type);
if (rc) {
pr_err("Failed to create video instance, core: %d, type = %d\n",
core->id, vid_dev->type);
rc = -ENOMEM;
goto fail_open;
}
INIT_LIST_HEAD(&v4l2_inst->registered_bufs);
rc = msm_vidc_v4l2_setup_event_queue(&v4l2_inst->vidc_inst, vdev);
clear_bit(V4L2_FL_USES_V4L2_FH, &vdev->flags);
filp->private_data = &(v4l2_inst->vidc_inst.event_handler);
return rc;
fail_open:
msm_smem_delete_client(v4l2_inst->mem_client);
fail_mem_client:
kfree(v4l2_inst);
fail_nomem:
return rc;
}
static int msm_v4l2_close(struct file *filp)
{
int rc;
struct list_head *ptr, *next;
struct buffer_info *binfo;
struct msm_vidc_inst *vidc_inst;
struct msm_v4l2_vid_inst *v4l2_inst;
vidc_inst = get_vidc_inst(filp, NULL);
v4l2_inst = get_v4l2_inst(filp, NULL);
rc = msm_vidc_close(vidc_inst);
list_for_each_safe(ptr, next, &v4l2_inst->registered_bufs) {
binfo = list_entry(ptr, struct buffer_info, list);
list_del(&binfo->list);
msm_smem_free(v4l2_inst->mem_client, binfo->handle);
kfree(binfo);
}
msm_smem_delete_client(v4l2_inst->mem_client);
kfree(v4l2_inst);
return rc;
}
static int msm_v4l2_querycap(struct file *filp, void *fh,
struct v4l2_capability *cap)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(filp, fh);
return msm_vidc_querycap((void *)vidc_inst, cap);
}
int msm_v4l2_enum_fmt(struct file *file, void *fh,
struct v4l2_fmtdesc *f)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);
return msm_vidc_enum_fmt((void *)vidc_inst, f);
}
int msm_v4l2_s_fmt(struct file *file, void *fh,
struct v4l2_format *f)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);
return msm_vidc_s_fmt((void *)vidc_inst, f);
}
int msm_v4l2_g_fmt(struct file *file, void *fh,
struct v4l2_format *f)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);
return msm_vidc_g_fmt((void *)vidc_inst, f);
}
int msm_v4l2_s_ctrl(struct file *file, void *fh,
struct v4l2_control *a)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);
return msm_vidc_s_ctrl((void *)vidc_inst, a);
}
int msm_v4l2_g_ctrl(struct file *file, void *fh,
struct v4l2_control *a)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);
return msm_vidc_g_ctrl((void *)vidc_inst, a);
}
int msm_v4l2_reqbufs(struct file *file, void *fh,
struct v4l2_requestbuffers *b)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);
struct msm_v4l2_vid_inst *v4l2_inst;
struct list_head *ptr, *next;
int rc;
struct buffer_info *bi;
struct v4l2_buffer buffer_info;
v4l2_inst = get_v4l2_inst(file, NULL);
if (b->count == 0) {
list_for_each_safe(ptr, next, &v4l2_inst->registered_bufs) {
bi = list_entry(ptr, struct buffer_info, list);
if (bi->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
buffer_info.type = bi->type;
buffer_info.m.planes[0].reserved[0] =
bi->fd;
buffer_info.m.planes[0].reserved[1] =
bi->buff_off;
buffer_info.m.planes[0].length = bi->size;
buffer_info.m.planes[0].m.userptr =
bi->uvaddr;
buffer_info.length = 1;
pr_err("Releasing buffer: %d, %d, %d\n",
buffer_info.m.planes[0].reserved[0],
buffer_info.m.planes[0].reserved[1],
buffer_info.m.planes[0].length);
rc = msm_vidc_release_buf(&v4l2_inst->vidc_inst,
&buffer_info);
list_del(&bi->list);
msm_smem_free(v4l2_inst->mem_client,
bi->handle);
kfree(bi);
}
}
}
return msm_vidc_reqbufs((void *)vidc_inst, b);
}
int msm_v4l2_prepare_buf(struct file *file, void *fh,
struct v4l2_buffer *b)
{
struct msm_smem *handle;
struct buffer_info *binfo;
struct msm_vidc_inst *vidc_inst;
struct msm_v4l2_vid_inst *v4l2_inst;
int i, rc = 0;
vidc_inst = get_vidc_inst(file, fh);
v4l2_inst = get_v4l2_inst(file, fh);
if (!v4l2_inst->mem_client) {
pr_err("Failed to get memory client\n");
rc = -ENOMEM;
goto exit;
}
for (i = 0; i < b->length; ++i) {
binfo = get_registered_buf(&v4l2_inst->registered_bufs,
b->m.planes[i].reserved[0],
b->m.planes[i].reserved[1],
b->m.planes[i].length);
if (binfo) {
pr_err("This memory region has already been prepared\n");
rc = -EINVAL;
goto exit;
}
binfo = kzalloc(sizeof(*binfo), GFP_KERNEL);
if (!binfo) {
pr_err("Out of memory\n");
rc = -ENOMEM;
goto exit;
}
handle = msm_smem_user_to_kernel(v4l2_inst->mem_client,
b->m.planes[i].reserved[0],
b->m.planes[i].reserved[1]);
if (!handle) {
pr_err("Failed to get device buffer address\n");
kfree(binfo);
goto exit;
}
binfo->type = b->type;
binfo->fd = b->m.planes[i].reserved[0];
binfo->buff_off = b->m.planes[i].reserved[1];
binfo->size = b->m.planes[i].length;
binfo->uvaddr = b->m.planes[i].m.userptr;
binfo->handle = handle;
pr_debug("Registering buffer: %d, %d, %d\n",
b->m.planes[i].reserved[0],
b->m.planes[i].reserved[1],
b->m.planes[i].length);
list_add_tail(&binfo->list, &v4l2_inst->registered_bufs);
b->m.planes[i].m.userptr = handle->device_addr;
}
rc = msm_vidc_prepare_buf(&v4l2_inst->vidc_inst, b);
exit:
return rc;
}
int msm_v4l2_qbuf(struct file *file, void *fh,
struct v4l2_buffer *b)
{
struct msm_vidc_inst *vidc_inst;
struct msm_v4l2_vid_inst *v4l2_inst;
struct buffer_info *binfo;
int rc = 0;
int i;
vidc_inst = get_vidc_inst(file, fh);
v4l2_inst = get_v4l2_inst(file, fh);
for (i = 0; i < b->length; ++i) {
binfo = get_registered_buf(&v4l2_inst->registered_bufs,
b->m.planes[i].reserved[0],
b->m.planes[i].reserved[1],
b->m.planes[i].length);
if (!binfo) {
pr_err("This buffer is not registered: %d, %d, %d\n",
b->m.planes[i].reserved[0],
b->m.planes[i].reserved[1],
b->m.planes[i].length);
rc = -EINVAL;
goto err_invalid_buff;
}
b->m.planes[i].m.userptr = binfo->handle->device_addr;
pr_debug("Queueing device address = %ld\n",
binfo->handle->device_addr);
}
rc = msm_vidc_qbuf(&v4l2_inst->vidc_inst, b);
err_invalid_buff:
return rc;
}
int msm_v4l2_dqbuf(struct file *file, void *fh,
struct v4l2_buffer *b)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);
return msm_vidc_dqbuf((void *)vidc_inst, b);
}
int msm_v4l2_streamon(struct file *file, void *fh,
enum v4l2_buf_type i)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);
return msm_vidc_streamon((void *)vidc_inst, i);
}
int msm_v4l2_streamoff(struct file *file, void *fh,
enum v4l2_buf_type i)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);
return msm_vidc_streamoff((void *)vidc_inst, i);
}
static int msm_v4l2_subscribe_event(struct v4l2_fh *fh,
struct v4l2_event_subscription *sub)
{
int rc = 0;
if (sub->type == V4L2_EVENT_ALL)
sub->type = V4L2_EVENT_PRIVATE_START + V4L2_EVENT_VIDC_BASE;
rc = v4l2_event_subscribe(fh, sub, 0);
return rc;
}
static int msm_v4l2_unsubscribe_event(struct v4l2_fh *fh,
struct v4l2_event_subscription *sub)
{
int rc = 0;
rc = v4l2_event_unsubscribe(fh, sub);
return rc;
}
static int msm_v4l2_decoder_cmd(struct file *file, void *fh,
struct v4l2_decoder_cmd *dec)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);
return msm_vidc_decoder_cmd((void *)vidc_inst, dec);
}
static const struct v4l2_ioctl_ops msm_v4l2_ioctl_ops = {
.vidioc_querycap = msm_v4l2_querycap,
.vidioc_enum_fmt_vid_cap_mplane = msm_v4l2_enum_fmt,
.vidioc_enum_fmt_vid_out_mplane = msm_v4l2_enum_fmt,
.vidioc_s_fmt_vid_cap_mplane = msm_v4l2_s_fmt,
.vidioc_s_fmt_vid_out_mplane = msm_v4l2_s_fmt,
.vidioc_g_fmt_vid_cap_mplane = msm_v4l2_g_fmt,
.vidioc_g_fmt_vid_out_mplane = msm_v4l2_g_fmt,
.vidioc_reqbufs = msm_v4l2_reqbufs,
.vidioc_prepare_buf = msm_v4l2_prepare_buf,
.vidioc_qbuf = msm_v4l2_qbuf,
.vidioc_dqbuf = msm_v4l2_dqbuf,
.vidioc_streamon = msm_v4l2_streamon,
.vidioc_streamoff = msm_v4l2_streamoff,
.vidioc_s_ctrl = msm_v4l2_s_ctrl,
.vidioc_g_ctrl = msm_v4l2_g_ctrl,
.vidioc_subscribe_event = msm_v4l2_subscribe_event,
.vidioc_unsubscribe_event = msm_v4l2_unsubscribe_event,
.vidioc_decoder_cmd = msm_v4l2_decoder_cmd,
};
static const struct v4l2_ioctl_ops msm_v4l2_enc_ioctl_ops = {
};
static unsigned int msm_v4l2_poll(struct file *filp,
struct poll_table_struct *pt)
{
struct msm_vidc_inst *vidc_inst = get_vidc_inst(filp, NULL);
return msm_vidc_poll((void *)vidc_inst, filp, pt);
}
static const struct v4l2_file_operations msm_v4l2_vidc_fops = {
.owner = THIS_MODULE,
.open = msm_v4l2_open,
.release = msm_v4l2_close,
.ioctl = video_ioctl2,
.poll = msm_v4l2_poll,
};
void msm_vidc_release_video_device(struct video_device *pvdev)
{
}
static int msm_vidc_initialize_core(struct platform_device *pdev,
struct msm_vidc_core *core)
{
struct resource *res;
int i = 0;
if (!core)
return -EINVAL;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
pr_err("Failed to get IORESOURCE_MEM\n");
return -ENODEV;
}
core->register_base = res->start;
core->register_size = resource_size(res);
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
pr_err("Failed to get IORESOURCE_IRQ\n");
return -ENODEV;
}
core->irq = res->start;
INIT_LIST_HEAD(&core->instances);
mutex_init(&core->sync_lock);
spin_lock_init(&core->lock);
core->base_addr = 0x34f00000;
core->state = VIDC_CORE_UNINIT;
for (i = SYS_MSG_INDEX(SYS_MSG_START);
i <= SYS_MSG_INDEX(SYS_MSG_END); i++) {
init_completion(&core->completions[i]);
}
return 0;
}
static int __devinit msm_vidc_probe(struct platform_device *pdev)
{
int rc = 0;
struct msm_vidc_core *core;
unsigned long flags;
char debugfs_name[MAX_DEBUGFS_NAME];
core = kzalloc(sizeof(*core), GFP_KERNEL);
if (!core || !vidc_driver) {
pr_err("Failed to allocate memory for device core\n");
rc = -ENOMEM;
goto err_no_mem;
}
rc = msm_vidc_initialize_core(pdev, core);
if (rc) {
pr_err("Failed to init core\n");
goto err_v4l2_register;
}
rc = v4l2_device_register(&pdev->dev, &core->v4l2_dev);
if (rc) {
pr_err("Failed to register v4l2 device\n");
goto err_v4l2_register;
}
core->vdev[MSM_VIDC_DECODER].vdev.release =
msm_vidc_release_video_device;
core->vdev[MSM_VIDC_DECODER].vdev.fops = &msm_v4l2_vidc_fops;
core->vdev[MSM_VIDC_DECODER].vdev.ioctl_ops = &msm_v4l2_ioctl_ops;
core->vdev[MSM_VIDC_DECODER].type = MSM_VIDC_DECODER;
rc = video_register_device(&core->vdev[MSM_VIDC_DECODER].vdev,
VFL_TYPE_GRABBER, BASE_DEVICE_NUMBER);
if (rc) {
pr_err("Failed to register video decoder device");
goto err_dec_register;
}
video_set_drvdata(&core->vdev[MSM_VIDC_DECODER].vdev, core);
core->vdev[MSM_VIDC_ENCODER].vdev.release =
msm_vidc_release_video_device;
core->vdev[MSM_VIDC_ENCODER].vdev.fops = &msm_v4l2_vidc_fops;
core->vdev[MSM_VIDC_ENCODER].vdev.ioctl_ops = &msm_v4l2_ioctl_ops;
core->vdev[MSM_VIDC_ENCODER].type = MSM_VIDC_ENCODER;
rc = video_register_device(&core->vdev[MSM_VIDC_ENCODER].vdev,
VFL_TYPE_GRABBER, BASE_DEVICE_NUMBER + 1);
if (rc) {
pr_err("Failed to register video encoder device");
goto err_enc_register;
}
video_set_drvdata(&core->vdev[MSM_VIDC_ENCODER].vdev, core);
core->device = vidc_hal_add_device(core->id, core->base_addr,
core->register_base, core->register_size, core->irq,
&handle_cmd_response);
if (!core->device) {
pr_err("Failed to create interrupt handler");
goto err_cores_exceeded;
}
spin_lock_irqsave(&vidc_driver->lock, flags);
if (vidc_driver->num_cores + 1 > MSM_VIDC_CORES_MAX) {
spin_unlock_irqrestore(&vidc_driver->lock, flags);
pr_err("Maximum cores already exist, core_no = %d\n",
vidc_driver->num_cores);
goto err_cores_exceeded;
}
core->id = vidc_driver->num_cores++;
list_add_tail(&core->list, &vidc_driver->cores);
spin_unlock_irqrestore(&vidc_driver->lock, flags);
snprintf(debugfs_name, MAX_DEBUGFS_NAME, "core%d", core->id);
core->debugfs_root = debugfs_create_dir(debugfs_name,
vidc_driver->debugfs_root);
pdev->dev.platform_data = core;
return rc;
err_cores_exceeded:
video_unregister_device(&core->vdev[MSM_VIDC_ENCODER].vdev);
err_enc_register:
video_unregister_device(&core->vdev[MSM_VIDC_DECODER].vdev);
err_dec_register:
v4l2_device_unregister(&core->v4l2_dev);
err_v4l2_register:
kfree(core);
err_no_mem:
return rc;
}
static int __devexit msm_vidc_remove(struct platform_device *pdev)
{
int rc = 0;
struct msm_vidc_core *core = pdev->dev.platform_data;
vidc_hal_delete_device(core->device);
video_unregister_device(&core->vdev[MSM_VIDC_ENCODER].vdev);
video_unregister_device(&core->vdev[MSM_VIDC_DECODER].vdev);
v4l2_device_unregister(&core->v4l2_dev);
kfree(core);
return rc;
}
static const struct of_device_id msm_vidc_dt_match[] = {
{.compatible = "qcom,msm-vidc"},
};
MODULE_DEVICE_TABLE(of, msm_vidc_dt_match);
static struct platform_driver msm_vidc_driver = {
.probe = msm_vidc_probe,
.remove = msm_vidc_remove,
.driver = {
.name = "msm_vidc",
.owner = THIS_MODULE,
.of_match_table = msm_vidc_dt_match,
},
};
static int __init msm_vidc_init(void)
{
int rc = 0;
vidc_driver = kzalloc(sizeof(*vidc_driver),
GFP_KERNEL);
if (!vidc_driver) {
pr_err("Failed to allocate memroy for msm_vidc_drv\n");
return -ENOMEM;
}
INIT_LIST_HEAD(&vidc_driver->cores);
spin_lock_init(&vidc_driver->lock);
vidc_driver->debugfs_root = debugfs_create_dir("msm_vidc", NULL);
if (!vidc_driver->debugfs_root)
pr_err("Failed to create debugfs for msm_vidc\n");
rc = platform_driver_register(&msm_vidc_driver);
if (rc) {
pr_err("Failed to register platform driver\n");
kfree(vidc_driver);
vidc_driver = NULL;
}
return rc;
}
static void __exit msm_vidc_exit(void)
{
platform_driver_unregister(&msm_vidc_driver);
debugfs_remove_recursive(vidc_driver->debugfs_root);
kfree(vidc_driver);
vidc_driver = NULL;
}
module_init(msm_vidc_init);
module_exit(msm_vidc_exit);

View File

@@ -0,0 +1,893 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/slab.h>
#include "msm_vidc_internal.h"
#include "msm_vidc_common.h"
#include "vidc_hal_api.h"
#include "msm_smem.h"
#define MSM_VDEC_DVC_NAME "msm_vdec_8974"
#define MAX_PLANES 1
#define DEFAULT_HEIGHT 720
#define DEFAULT_WIDTH 1280
#define MIN_NUM_OUTPUT_BUFFERS 2
#define MAX_NUM_OUTPUT_BUFFERS 6
static const char *const mpeg_video_vidc_divx_format[] = {
"DIVX Format 3",
"DIVX Format 4",
"DIVX Format 5",
"DIVX Format 6",
NULL
};
static const char *mpeg_video_stream_format[] = {
"NAL Format Start Codes",
"NAL Format One NAL Per Buffer",
"NAL Format One Byte Length",
"NAL Format Two Byte Length",
"NAL Format Four Byte Length",
NULL
};
static const char *const mpeg_video_output_order[] = {
"Display Order",
"Decode Order",
NULL
};
static const struct msm_vidc_ctrl msm_vdec_ctrls[] = {
{
.id = V4L2_CID_MPEG_VIDC_VIDEO_STREAM_FORMAT,
.name = "NAL Format",
.type = V4L2_CTRL_TYPE_MENU,
.minimum = V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_STARTCODES,
.maximum = V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_FOUR_BYTE_LENGTH,
.default_value = V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_STARTCODES,
.menu_skip_mask = ~(
(1 << V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_STARTCODES) |
(1 << V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_ONE_NAL_PER_BUFFER) |
(1 << V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_ONE_BYTE_LENGTH) |
(1 << V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_TWO_BYTE_LENGTH) |
(1 << V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_FOUR_BYTE_LENGTH)
),
.qmenu = mpeg_video_stream_format,
.step = 0,
},
{
.id = V4L2_CID_MPEG_VIDC_VIDEO_OUTPUT_ORDER,
.name = "Output Order",
.type = V4L2_CTRL_TYPE_MENU,
.minimum = V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DISPLAY,
.maximum = V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DECODE,
.default_value = V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DISPLAY,
.menu_skip_mask = ~(
(1 << V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DISPLAY) |
(1 << V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DECODE)
),
.qmenu = mpeg_video_output_order,
.step = 0,
},
{
.id = V4L2_CID_MPEG_VIDC_VIDEO_ENABLE_PICTURE_TYPE,
.name = "Picture Type Decoding",
.type = V4L2_CTRL_TYPE_INTEGER,
.minimum = 1,
.maximum = 15,
.default_value = 15,
.step = 1,
.menu_skip_mask = 0,
.qmenu = NULL,
},
{
.id = V4L2_CID_MPEG_VIDC_VIDEO_KEEP_ASPECT_RATIO,
.name = "Keep Aspect Ratio",
.type = V4L2_CTRL_TYPE_BOOLEAN,
.minimum = 0,
.maximum = 1,
.default_value = 0,
.step = 1,
.menu_skip_mask = 0,
.qmenu = NULL,
},
{
.id = V4L2_CID_MPEG_VIDC_VIDEO_POST_LOOP_DEBLOCKER_MODE,
.name = "Deblocker Mode",
.type = V4L2_CTRL_TYPE_BOOLEAN,
.minimum = 0,
.maximum = 1,
.default_value = 0,
.step = 1,
.menu_skip_mask = 0,
.qmenu = NULL,
},
{
.id = V4L2_CID_MPEG_VIDC_VIDEO_DIVX_FORMAT,
.name = "Divx Format",
.type = V4L2_CTRL_TYPE_MENU,
.minimum = V4L2_MPEG_VIDC_VIDEO_DIVX_FORMAT_4,
.maximum = V4L2_MPEG_VIDC_VIDEO_DIVX_FORMAT_6,
.default_value = V4L2_MPEG_VIDC_VIDEO_DIVX_FORMAT_4,
.menu_skip_mask = ~(
(1 << V4L2_MPEG_VIDC_VIDEO_DIVX_FORMAT_4) |
(1 << V4L2_MPEG_VIDC_VIDEO_DIVX_FORMAT_5) |
(1 << V4L2_MPEG_VIDC_VIDEO_DIVX_FORMAT_6)
),
.qmenu = mpeg_video_vidc_divx_format,
.step = 0,
},
{
.id = V4L2_CID_MPEG_VIDC_VIDEO_MB_ERROR_MAP_REPORTING,
.name = "MB Error Map Reporting",
.type = V4L2_CTRL_TYPE_BOOLEAN,
.minimum = 0,
.maximum = 1,
.default_value = 0,
.step = 1,
.menu_skip_mask = 0,
.qmenu = NULL,
},
{
.id = V4L2_CID_MPEG_VIDC_VIDEO_CONTINUE_DATA_TRANSFER,
.name = "control",
.type = V4L2_CTRL_TYPE_BOOLEAN,
.minimum = 0,
.maximum = 1,
.default_value = 0,
.step = 1,
.menu_skip_mask = 0,
.qmenu = NULL,
},
};
#define NUM_CTRLS ARRAY_SIZE(msm_vdec_ctrls)
static u32 get_frame_size_nv12(int plane,
u32 height, u32 width)
{
return (ALIGN(height, 32) * ALIGN(width, 32) * 3) / 2;
}
static u32 get_frame_size_nv21(int plane,
u32 height, u32 width)
{
return height * width * 2;
}
static u32 get_frame_size_compressed(int plane,
u32 height, u32 width)
{
return 0x500000;
}
static const struct msm_vidc_format vdec_formats[] = {
{
.name = "YCbCr Semiplanar 4:2:0",
.description = "Y/CbCr 4:2:0",
.fourcc = V4L2_PIX_FMT_NV12,
.num_planes = 1,
.get_frame_size = get_frame_size_nv12,
.type = CAPTURE_PORT,
},
{
.name = "Mpeg4",
.description = "Mpeg4 compressed format",
.fourcc = V4L2_PIX_FMT_MPEG4,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
{
.name = "Mpeg2",
.description = "Mpeg2 compressed format",
.fourcc = V4L2_PIX_FMT_MPEG2,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
{
.name = "H263",
.description = "H263 compressed format",
.fourcc = V4L2_PIX_FMT_H263,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
{
.name = "H264",
.description = "H264 compressed format",
.fourcc = V4L2_PIX_FMT_H264,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
{
.name = "YCrCb Semiplanar 4:2:0",
.description = "Y/CrCb 4:2:0",
.fourcc = V4L2_PIX_FMT_NV21,
.num_planes = 1,
.get_frame_size = get_frame_size_nv21,
.type = CAPTURE_PORT,
},
{
.name = "DIVX 311",
.description = "DIVX 311 compressed format",
.fourcc = V4L2_PIX_FMT_DIVX_311,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
},
{
.name = "DIVX",
.description = "DIVX 4/5/6 compressed format",
.fourcc = V4L2_PIX_FMT_DIVX,
.num_planes = 1,
.get_frame_size = get_frame_size_compressed,
.type = OUTPUT_PORT,
}
};
int msm_vdec_streamon(struct msm_vidc_inst *inst, enum v4l2_buf_type i)
{
int rc = 0;
struct vb2_queue *q;
q = msm_comm_get_vb2q(inst, i);
if (!q) {
pr_err("Failed to find buffer queue for type = %d\n", i);
return -EINVAL;
}
pr_debug("Calling streamon\n");
rc = vb2_streamon(q, i);
if (rc)
pr_err("streamon failed on port: %d\n", i);
return rc;
}
int msm_vdec_streamoff(struct msm_vidc_inst *inst, enum v4l2_buf_type i)
{
int rc = 0;
struct vb2_queue *q;
q = msm_comm_get_vb2q(inst, i);
if (!q) {
pr_err("Failed to find buffer queue for type = %d\n", i);
return -EINVAL;
}
pr_debug("Calling streamoff\n");
rc = vb2_streamoff(q, i);
if (rc)
pr_err("streamoff failed on port: %d\n", i);
return rc;
}
int msm_vdec_prepare_buf(struct msm_vidc_inst *inst,
struct v4l2_buffer *b)
{
int rc = 0;
int i;
struct vidc_buffer_addr_info buffer_info;
switch (b->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
for (i = 0; i < b->length; i++) {
pr_err("device_addr = %ld, size = %d\n",
b->m.planes[i].m.userptr,
b->m.planes[i].length);
buffer_info.buffer_size = b->m.planes[i].length;
buffer_info.buffer_type = HAL_BUFFER_OUTPUT;
buffer_info.num_buffers = 1;
buffer_info.align_device_addr =
b->m.planes[i].m.userptr;
buffer_info.extradata_size = 0;
buffer_info.extradata_addr = 0;
rc = vidc_hal_session_set_buffers((void *)inst->session,
&buffer_info);
if (rc) {
pr_err("vidc_hal_session_set_buffers failed");
break;
}
}
break;
default:
pr_err("Buffer type not recognized: %d\n", b->type);
break;
}
return rc;
}
int msm_vdec_release_buf(struct msm_vidc_inst *inst,
struct v4l2_buffer *b)
{
int rc = 0;
int i;
struct vidc_buffer_addr_info buffer_info;
switch (b->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
for (i = 0; i < b->length; i++) {
pr_debug("Release device_addr = %ld, size = %d\n",
b->m.planes[i].m.userptr,
b->m.planes[i].length);
buffer_info.buffer_size = b->m.planes[i].length;
buffer_info.buffer_type = HAL_BUFFER_OUTPUT;
buffer_info.num_buffers = 1;
buffer_info.align_device_addr =
b->m.planes[i].m.userptr;
buffer_info.extradata_addr = 0;
rc = vidc_hal_session_release_buffers(
(void *)inst->session, &buffer_info);
if (rc)
pr_err("vidc_hal_session_release_buffers failed");
}
break;
default:
pr_err("Buffer type not recognized: %d\n", b->type);
break;
}
return rc;
}
int msm_vdec_qbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b)
{
struct vb2_queue *q = NULL;
int rc = 0;
q = msm_comm_get_vb2q(inst, b->type);
if (!q) {
pr_err("Failed to find buffer queue for type = %d\n", b->type);
return -EINVAL;
}
rc = vb2_qbuf(q, b);
if (rc)
pr_err("Failed to qbuf, %d\n", rc);
return rc;
}
int msm_vdec_dqbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b)
{
struct vb2_queue *q = NULL;
int rc = 0;
q = msm_comm_get_vb2q(inst, b->type);
if (!q) {
pr_err("Failed to find buffer queue for type = %d\n", b->type);
return -EINVAL;
}
rc = vb2_dqbuf(q, b, true);
if (rc)
pr_err("Failed to dqbuf, %d\n", rc);
return rc;
}
int msm_vdec_reqbufs(struct msm_vidc_inst *inst, struct v4l2_requestbuffers *b)
{
struct vb2_queue *q = NULL;
int rc = 0;
if (!inst || !b) {
pr_err("Invalid input, inst = %p, buffer = %p\n", inst, b);
return -EINVAL;
}
q = msm_comm_get_vb2q(inst, b->type);
if (!q) {
pr_err("Failed to find buffer queue for type = %d\n", b->type);
return -EINVAL;
}
rc = vb2_reqbufs(q, b);
if (rc)
pr_err("Failed to get reqbufs, %d\n", rc);
return rc;
}
int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
{
const struct msm_vidc_format *fmt = NULL;
int rc = 0;
int i;
if (!inst || !f) {
pr_err("Invalid input, inst = %p, format = %p\n", inst, f);
return -EINVAL;
}
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
fmt = inst->fmts[CAPTURE_PORT];
else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
fmt = inst->fmts[OUTPUT_PORT];
if (fmt) {
f->fmt.pix_mp.pixelformat = fmt->fourcc;
if (inst->in_reconfig == true) {
inst->height = inst->reconfig_height;
inst->width = inst->reconfig_width;
}
f->fmt.pix_mp.height = inst->height;
f->fmt.pix_mp.width = inst->width;
for (i = 0; i < fmt->num_planes; ++i) {
f->fmt.pix_mp.plane_fmt[i].sizeimage =
fmt->get_frame_size(i, inst->height, inst->width);
}
} else {
pr_err("Buf type not recognized, type = %d\n",
f->type);
rc = -EINVAL;
}
return rc;
}
int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
{
const struct msm_vidc_format *fmt = NULL;
int rc = 0;
int i;
if (!inst || !f) {
pr_err("Invalid input, inst = %p, format = %p\n", inst, f);
return -EINVAL;
}
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
inst->width = f->fmt.pix_mp.width;
inst->height = f->fmt.pix_mp.height;
fmt = msm_comm_get_pixel_fmt_fourcc(vdec_formats,
ARRAY_SIZE(vdec_formats), f->fmt.pix_mp.pixelformat,
CAPTURE_PORT);
if (fmt && fmt->type != CAPTURE_PORT) {
pr_err("Format: %d not supported on CAPTURE port\n",
f->fmt.pix_mp.pixelformat);
rc = -EINVAL;
goto err_invalid_fmt;
}
} else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
fmt = msm_comm_get_pixel_fmt_fourcc(vdec_formats,
ARRAY_SIZE(vdec_formats), f->fmt.pix_mp.pixelformat,
OUTPUT_PORT);
if (fmt && fmt->type != OUTPUT_PORT) {
pr_err("Format: %d not supported on OUTPUT port\n",
f->fmt.pix_mp.pixelformat);
rc = -EINVAL;
goto err_invalid_fmt;
}
}
if (fmt) {
for (i = 0; i < fmt->num_planes; ++i) {
f->fmt.pix_mp.plane_fmt[i].sizeimage =
fmt->get_frame_size(i, f->fmt.pix_mp.height,
f->fmt.pix_mp.width);
}
inst->fmts[fmt->type] = fmt;
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
rc = msm_comm_try_state(inst, MSM_VIDC_OPEN);
if (rc) {
pr_err("Failed to open instance\n");
goto err_invalid_fmt;
}
}
} else {
pr_err("Buf type not recognized, type = %d\n",
f->type);
rc = -EINVAL;
}
err_invalid_fmt:
return rc;
}
int msm_vdec_querycap(struct msm_vidc_inst *inst, struct v4l2_capability *cap)
{
if (!inst || !cap) {
pr_err("Invalid input, inst = %p, cap = %p\n", inst, cap);
return -EINVAL;
}
strlcpy(cap->driver, MSM_VIDC_DRV_NAME, sizeof(cap->driver));
strlcpy(cap->card, MSM_VDEC_DVC_NAME, sizeof(cap->card));
cap->bus_info[0] = 0;
cap->version = MSM_VIDC_VERSION;
cap->capabilities = V4L2_CAP_VIDEO_CAPTURE_MPLANE |
V4L2_CAP_VIDEO_OUTPUT_MPLANE |
V4L2_CAP_STREAMING;
memset(cap->reserved, 0, sizeof(cap->reserved));
return 0;
}
int msm_vdec_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
{
const struct msm_vidc_format *fmt = NULL;
int rc = 0;
if (!inst || !f) {
pr_err("Invalid input, inst = %p, f = %p\n", inst, f);
return -EINVAL;
}
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
fmt = msm_comm_get_pixel_fmt_index(vdec_formats,
ARRAY_SIZE(vdec_formats), f->index, CAPTURE_PORT);
} else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
fmt = msm_comm_get_pixel_fmt_index(vdec_formats,
ARRAY_SIZE(vdec_formats), f->index, OUTPUT_PORT);
f->flags = V4L2_FMT_FLAG_COMPRESSED;
}
memset(f->reserved, 0 , sizeof(f->reserved));
if (fmt) {
strlcpy(f->description, fmt->description,
sizeof(f->description));
f->pixelformat = fmt->fourcc;
} else {
pr_err("No more formats found\n");
rc = -EINVAL;
}
return rc;
}
static int msm_vdec_queue_setup(struct vb2_queue *q,
const struct v4l2_format *fmt,
unsigned int *num_buffers,
unsigned int *num_planes, unsigned int sizes[],
void *alloc_ctxs[])
{
int i, rc = 0;
struct msm_vidc_inst *inst;
struct hal_frame_size frame_sz;
unsigned long flags;
if (!q || !q->drv_priv) {
pr_err("Invalid input, q = %p\n", q);
return -EINVAL;
}
inst = q->drv_priv;
switch (q->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
*num_planes = 1;
if (*num_buffers < MIN_NUM_OUTPUT_BUFFERS ||
*num_buffers > MAX_NUM_OUTPUT_BUFFERS)
*num_buffers = MIN_NUM_OUTPUT_BUFFERS;
for (i = 0; i < *num_planes; i++) {
sizes[i] = inst->fmts[OUTPUT_PORT]->get_frame_size(
i, inst->height, inst->width);
}
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
pr_debug("Getting bufreqs on capture plane\n");
rc = msm_comm_try_state(inst, MSM_VIDC_OPEN_DONE);
if (rc) {
pr_err("Failed to open instance\n");
break;
}
frame_sz.buffer_type = HAL_BUFFER_OUTPUT;
frame_sz.width = inst->width;
frame_sz.height = inst->height;
pr_debug("width = %d, height = %d\n",
frame_sz.width, frame_sz.height);
rc = vidc_hal_session_set_property((void *)inst->session,
HAL_PARAM_FRAME_SIZE, &frame_sz);
if (rc) {
pr_err("Failed to set hal property for framesize\n");
break;
}
rc = msm_comm_try_get_bufreqs(inst);
if (rc) {
pr_err("Failed to get buffer requirements: %d\n", rc);
break;
}
*num_planes = 1;
spin_lock_irqsave(&inst->lock, flags);
*num_buffers = inst->buff_req.buffer[1].buffer_count_actual;
spin_unlock_irqrestore(&inst->lock, flags);
pr_debug("size = %d, alignment = %d\n",
inst->buff_req.buffer[1].buffer_size,
inst->buff_req.buffer[1].buffer_alignment);
for (i = 0; i < *num_planes; i++) {
sizes[i] = inst->fmts[CAPTURE_PORT]->get_frame_size(
i, inst->height, inst->width);
}
break;
default:
pr_err("Invalid q type = %d\n", q->type);
rc = -EINVAL;
break;
}
return rc;
}
static inline int start_streaming(struct msm_vidc_inst *inst)
{
int rc = 0;
unsigned long flags;
struct vb2_buf_entry *temp;
struct list_head *ptr, *next;
struct v4l2_control control;
struct hal_nal_stream_format_supported stream_format;
struct hal_enable_picture enable_picture;
struct hal_enable hal_property;
u32 control_idx = 0;
enum hal_property property_id = 0;
u32 property_val = 0;
void *pdata;
rc = msm_comm_set_scratch_buffers(inst);
if (rc) {
pr_err("Failed to set scratch buffers: %d\n", rc);
goto fail_start;
}
for (; control_idx < NUM_CTRLS; control_idx++) {
control.id = msm_vdec_ctrls[control_idx].id;
rc = v4l2_g_ctrl(&inst->ctrl_handler, &control);
if (rc) {
pr_err("Failed to get control value for ID=%d\n",
msm_vdec_ctrls[control_idx].id);
} else {
property_id = 0;
switch (control.id) {
case V4L2_CID_MPEG_VIDC_VIDEO_STREAM_FORMAT:
property_id =
HAL_PARAM_NAL_STREAM_FORMAT_SELECT;
stream_format.nal_stream_format_supported =
(0x00000001 << control.value);
pdata = &stream_format;
break;
case V4L2_CID_MPEG_VIDC_VIDEO_OUTPUT_ORDER:
property_id = HAL_PARAM_VDEC_OUTPUT_ORDER;
property_val = control.value;
pdata = &property_val;
break;
case V4L2_CID_MPEG_VIDC_VIDEO_ENABLE_PICTURE_TYPE:
property_id =
HAL_PARAM_VDEC_PICTURE_TYPE_DECODE;
enable_picture.picture_type = control.value;
pdata = &enable_picture;
break;
case V4L2_CID_MPEG_VIDC_VIDEO_KEEP_ASPECT_RATIO:
property_id =
HAL_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO;
hal_property.enable = control.value;
pdata = &hal_property;
break;
case V4L2_CID_MPEG_VIDC_VIDEO_POST_LOOP_DEBLOCKER_MODE:
property_id =
HAL_CONFIG_VDEC_POST_LOOP_DEBLOCKER;
hal_property.enable = control.value;
pdata = &hal_property;
break;
case V4L2_CID_MPEG_VIDC_VIDEO_DIVX_FORMAT:
property_id = HAL_PARAM_DIVX_FORMAT;
property_val = control.value;
pdata = &property_val;
break;
case V4L2_CID_MPEG_VIDC_VIDEO_MB_ERROR_MAP_REPORTING:
property_id =
HAL_CONFIG_VDEC_MB_ERROR_MAP_REPORTING;
hal_property.enable = control.value;
pdata = &hal_property;
break;
case V4L2_CID_MPEG_VIDC_VIDEO_CONTINUE_DATA_TRANSFER:
property_id =
HAL_PARAM_VDEC_CONTINUE_DATA_TRANSFER;
hal_property.enable = control.value;
pdata = &hal_property;
break;
default:
break;
}
if (property_id) {
pr_err("Control: HAL property=%x,ctrl_id=%x,ctrl_value=%d\n",
property_id,
msm_vdec_ctrls[control_idx].id,
control.value);
rc = vidc_hal_session_set_property((void *)
inst->session, property_id,
pdata);
}
if (rc)
pr_err("Failed to set hal property for framesize\n");
}
}
rc = msm_comm_try_state(inst, MSM_VIDC_START_DONE);
if (rc) {
pr_err("Failed to move inst: %p to start done state\n",
inst);
goto fail_start;
}
spin_lock_irqsave(&inst->lock, flags);
if (!list_empty(&inst->pendingq)) {
list_for_each_safe(ptr, next, &inst->pendingq) {
temp = list_entry(ptr, struct vb2_buf_entry, list);
rc = msm_comm_qbuf(temp->vb);
if (rc) {
pr_err("Failed to qbuf to hardware\n");
break;
}
list_del(&temp->list);
kfree(temp);
}
}
spin_unlock_irqrestore(&inst->lock, flags);
return rc;
fail_start:
return rc;
}
static int msm_vdec_start_streaming(struct vb2_queue *q, unsigned int count)
{
struct msm_vidc_inst *inst;
int rc = 0;
if (!q || !q->drv_priv) {
pr_err("Invalid input, q = %p\n", q);
return -EINVAL;
}
inst = q->drv_priv;
pr_debug("Streamon called on: %d capability\n", q->type);
switch (q->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
if (inst->vb2_bufq[CAPTURE_PORT].streaming)
rc = start_streaming(inst);
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
inst->in_reconfig = false;
if (inst->vb2_bufq[OUTPUT_PORT].streaming)
rc = start_streaming(inst);
break;
default:
pr_err("Q-type is not supported: %d\n", q->type);
rc = -EINVAL;
break;
}
return rc;
}
static int msm_vdec_stop_streaming(struct vb2_queue *q)
{
struct msm_vidc_inst *inst;
int rc = 0;
if (!q || !q->drv_priv) {
pr_err("Invalid input, q = %p\n", q);
return -EINVAL;
}
inst = q->drv_priv;
pr_debug("Streamoff called on: %d capability\n", q->type);
switch (q->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
if (!inst->vb2_bufq[CAPTURE_PORT].streaming)
rc = msm_comm_try_state(inst, MSM_VIDC_CLOSE_DONE);
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
if (!inst->vb2_bufq[OUTPUT_PORT].streaming)
rc = msm_comm_try_state(inst, MSM_VIDC_CLOSE_DONE);
break;
default:
pr_err("Q-type is not supported: %d\n", q->type);
rc = -EINVAL;
break;
}
if (rc)
pr_err("Failed to move inst: %p, cap = %d to state: %d\n",
inst, q->type, MSM_VIDC_CLOSE_DONE);
return rc;
}
static void msm_vdec_buf_queue(struct vb2_buffer *vb)
{
int rc;
rc = msm_comm_qbuf(vb);
if (rc)
pr_err("Failed to queue buffer: %d\n", rc);
}
static const struct vb2_ops msm_vdec_vb2q_ops = {
.queue_setup = msm_vdec_queue_setup,
.start_streaming = msm_vdec_start_streaming,
.buf_queue = msm_vdec_buf_queue,
.stop_streaming = msm_vdec_stop_streaming,
};
const struct vb2_ops *msm_vdec_get_vb2q_ops(void)
{
return &msm_vdec_vb2q_ops;
}
int msm_vdec_inst_init(struct msm_vidc_inst *inst)
{
int rc = 0;
if (!inst) {
pr_err("Invalid input = %p\n", inst);
return -EINVAL;
}
inst->fmts[OUTPUT_PORT] = &vdec_formats[1];
inst->fmts[CAPTURE_PORT] = &vdec_formats[0];
inst->height = DEFAULT_HEIGHT;
inst->width = DEFAULT_WIDTH;
return rc;
}
static int msm_vdec_op_s_ctrl(struct v4l2_ctrl *ctrl)
{
return 0;
}
static int msm_vdec_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
{
return 0;
}
static const struct v4l2_ctrl_ops msm_vdec_ctrl_ops = {
.s_ctrl = msm_vdec_op_s_ctrl,
.g_volatile_ctrl = msm_vdec_op_g_volatile_ctrl,
};
const struct v4l2_ctrl_ops *msm_vdec_get_ctrl_ops(void)
{
return &msm_vdec_ctrl_ops;
}
int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_control *ctrl)
{
return v4l2_s_ctrl(NULL, &inst->ctrl_handler, ctrl);
}
int msm_vdec_g_ctrl(struct msm_vidc_inst *inst, struct v4l2_control *ctrl)
{
return v4l2_g_ctrl(&inst->ctrl_handler, ctrl);
}
int msm_vdec_ctrl_init(struct msm_vidc_inst *inst)
{
int idx = 0;
struct v4l2_ctrl_config ctrl_cfg;
int ret_val = 0;
ret_val = v4l2_ctrl_handler_init(&inst->ctrl_handler, NUM_CTRLS);
if (ret_val) {
pr_err("CTRL ERR: Control handler init failed, %d\n",
inst->ctrl_handler.error);
return ret_val;
}
for (; idx < NUM_CTRLS; idx++) {
if (IS_PRIV_CTRL(msm_vdec_ctrls[idx].id)) {
/*add private control*/
ctrl_cfg.def = msm_vdec_ctrls[idx].default_value;
ctrl_cfg.flags = 0;
ctrl_cfg.id = msm_vdec_ctrls[idx].id;
/*ctrl_cfg.is_private =
* msm_vdec_ctrls[idx].is_private;
* ctrl_cfg.is_volatile =
* msm_vdec_ctrls[idx].is_volatile;*/
ctrl_cfg.max = msm_vdec_ctrls[idx].maximum;
ctrl_cfg.min = msm_vdec_ctrls[idx].minimum;
ctrl_cfg.menu_skip_mask =
msm_vdec_ctrls[idx].menu_skip_mask;
ctrl_cfg.name = msm_vdec_ctrls[idx].name;
ctrl_cfg.ops = &msm_vdec_ctrl_ops;
ctrl_cfg.step = msm_vdec_ctrls[idx].step;
ctrl_cfg.type = msm_vdec_ctrls[idx].type;
ctrl_cfg.qmenu = msm_vdec_ctrls[idx].qmenu;
v4l2_ctrl_new_custom(&inst->ctrl_handler,
&ctrl_cfg, NULL);
} else {
if (msm_vdec_ctrls[idx].type == V4L2_CTRL_TYPE_MENU) {
v4l2_ctrl_new_std_menu(&inst->ctrl_handler,
&msm_vdec_ctrl_ops,
msm_vdec_ctrls[idx].id,
msm_vdec_ctrls[idx].maximum,
msm_vdec_ctrls[idx].menu_skip_mask,
msm_vdec_ctrls[idx].default_value);
} else {
v4l2_ctrl_new_std(&inst->ctrl_handler,
&msm_vdec_ctrl_ops,
msm_vdec_ctrls[idx].id,
msm_vdec_ctrls[idx].minimum,
msm_vdec_ctrls[idx].maximum,
msm_vdec_ctrls[idx].step,
msm_vdec_ctrls[idx].default_value);
}
}
}
ret_val = inst->ctrl_handler.error;
if (ret_val)
pr_err("CTRL ERR: Error adding ctrls to ctrl handle, %d\n",
inst->ctrl_handler.error);
return ret_val;
}

View File

@@ -0,0 +1,36 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _MSM_VDEC_H_
#define _MSM_VDEC_H_
#include <media/msm_vidc.h>
#include "msm_vidc_internal.h"
int msm_vdec_inst_init(struct msm_vidc_inst *inst);
int msm_vdec_ctrl_init(struct msm_vidc_inst *inst);
int msm_vdec_querycap(void *instance, struct v4l2_capability *cap);
int msm_vdec_enum_fmt(void *instance, struct v4l2_fmtdesc *f);
int msm_vdec_s_fmt(void *instance, struct v4l2_format *f);
int msm_vdec_g_fmt(void *instance, struct v4l2_format *f);
int msm_vdec_s_ctrl(void *instance, struct v4l2_control *a);
int msm_vdec_g_ctrl(void *instance, struct v4l2_control *a);
int msm_vdec_reqbufs(void *instance, struct v4l2_requestbuffers *b);
int msm_vdec_prepare_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_vdec_release_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_vdec_qbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_vdec_dqbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_vdec_streamon(struct msm_vidc_inst *inst, enum v4l2_buf_type i);
int msm_vdec_streamoff(struct msm_vidc_inst *inst, enum v4l2_buf_type i);
struct vb2_ops *msm_vdec_get_vb2q_ops(void);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _MSM_VENC_H_
#define _MSM_VENC_H_
#include <media/msm_vidc.h>
#include "msm_vidc_internal.h"
int msm_venc_inst_init(struct msm_vidc_inst *inst);
int msm_venc_ctrl_init(struct msm_vidc_inst *inst);
int msm_venc_querycap(void *instance, struct v4l2_capability *cap);
int msm_venc_enum_fmt(void *instance, struct v4l2_fmtdesc *f);
int msm_venc_s_fmt(void *instance, struct v4l2_format *f);
int msm_venc_g_fmt(void *instance, struct v4l2_format *f);
int msm_venc_s_ctrl(void *instance, struct v4l2_control *a);
int msm_venc_g_ctrl(void *instance, struct v4l2_control *a);
int msm_venc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
int msm_venc_prepare_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_venc_qbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_venc_dqbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_venc_streamon(struct msm_vidc_inst *inst, enum v4l2_buf_type i);
int msm_venc_streamoff(struct msm_vidc_inst *inst, enum v4l2_buf_type i);
struct vb2_ops *msm_venc_get_vb2q_ops(void);
#endif

View File

@@ -0,0 +1,348 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/slab.h>
#include <media/msm_vidc.h>
#include "msm_vidc_internal.h"
#include "msm_vdec.h"
#include "msm_venc.h"
#include "msm_vidc_common.h"
#include "msm_smem.h"
int msm_vidc_poll(void *instance, struct file *filp,
struct poll_table_struct *wait)
{
int rc = 0;
struct msm_vidc_inst *inst = instance;
struct vb2_queue *outq = &inst->vb2_bufq[OUTPUT_PORT];
struct vb2_queue *capq = &inst->vb2_bufq[CAPTURE_PORT];
struct vb2_buffer *out_vb = NULL;
struct vb2_buffer *cap_vb = NULL;
unsigned long flags;
poll_wait(filp, &inst->event_handler.wait, wait);
if (v4l2_event_pending(&inst->event_handler))
return POLLPRI;
if (!outq->streaming && !capq->streaming) {
pr_err("Returning POLLERR from here: %d, %d\n",
outq->streaming, capq->streaming);
return POLLERR;
}
poll_wait(filp, &inst->event_handler.wait, wait);
if (v4l2_event_pending(&inst->event_handler))
return POLLPRI;
poll_wait(filp, &capq->done_wq, wait);
poll_wait(filp, &outq->done_wq, wait);
spin_lock_irqsave(&capq->done_lock, flags);
if (!list_empty(&capq->done_list))
cap_vb = list_first_entry(&capq->done_list, struct vb2_buffer,
done_entry);
if (cap_vb && (cap_vb->state == VB2_BUF_STATE_DONE
|| cap_vb->state == VB2_BUF_STATE_ERROR))
rc |= POLLIN | POLLRDNORM;
spin_unlock_irqrestore(&capq->done_lock, flags);
spin_lock_irqsave(&outq->done_lock, flags);
if (!list_empty(&outq->done_list))
out_vb = list_first_entry(&outq->done_list, struct vb2_buffer,
done_entry);
if (out_vb && (out_vb->state == VB2_BUF_STATE_DONE
|| out_vb->state == VB2_BUF_STATE_ERROR))
rc |= POLLOUT | POLLWRNORM;
spin_unlock_irqrestore(&outq->done_lock, flags);
return rc;
}
int msm_vidc_querycap(void *instance, struct v4l2_capability *cap)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_querycap(instance, cap);
else if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_querycap(instance, cap);
return -EINVAL;
}
int msm_vidc_enum_fmt(void *instance, struct v4l2_fmtdesc *f)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_enum_fmt(instance, f);
else if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_enum_fmt(instance, f);
return -EINVAL;
}
int msm_vidc_s_fmt(void *instance, struct v4l2_format *f)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_s_fmt(instance, f);
if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_s_fmt(instance, f);
return -EINVAL;
}
int msm_vidc_g_fmt(void *instance, struct v4l2_format *f)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_g_fmt(instance, f);
else if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_g_fmt(instance, f);
return -EINVAL;
}
int msm_vidc_s_ctrl(void *instance, struct v4l2_control *control)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_s_ctrl(instance, control);
if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_s_ctrl(instance, control);
return -EINVAL;
}
int msm_vidc_g_ctrl(void *instance, struct v4l2_control *control)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_g_ctrl(instance, control);
if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_g_ctrl(instance, control);
return -EINVAL;
}
int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_reqbufs(instance, b);
if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_reqbufs(instance, b);
return -EINVAL;
}
int msm_vidc_prepare_buf(void *instance, struct v4l2_buffer *b)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_prepare_buf(instance, b);
if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_prepare_buf(instance, b);
return -EINVAL;
}
int msm_vidc_release_buf(void *instance, struct v4l2_buffer *b)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_release_buf(instance, b);
return -EINVAL;
}
int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_qbuf(instance, b);
if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_qbuf(instance, b);
return -EINVAL;
}
int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_dqbuf(instance, b);
if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_dqbuf(instance, b);
return -EINVAL;
}
int msm_vidc_streamon(void *instance, enum v4l2_buf_type i)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_streamon(instance, i);
if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_streamon(instance, i);
return -EINVAL;
}
int msm_vidc_streamoff(void *instance, enum v4l2_buf_type i)
{
struct msm_vidc_inst *inst = instance;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_streamoff(instance, i);
if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_streamoff(instance, i);
return -EINVAL;
}
void *vidc_get_userptr(void *alloc_ctx, unsigned long vaddr,
unsigned long size, int write)
{
return NULL;
}
void vidc_put_userptr(void *buf_priv)
{
}
static const struct vb2_mem_ops msm_vidc_vb2_mem_ops = {
.get_userptr = vidc_get_userptr,
.put_userptr = vidc_put_userptr,
};
static inline int vb2_bufq_init(struct msm_vidc_inst *inst,
enum v4l2_buf_type type, enum session_type sess)
{
struct vb2_queue *q = NULL;
if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
q = &inst->vb2_bufq[CAPTURE_PORT];
} else if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
q = &inst->vb2_bufq[OUTPUT_PORT];
} else {
pr_err("buf_type = %d not recognised\n", type);
return -EINVAL;
}
q->type = type;
q->io_modes = VB2_MMAP | VB2_USERPTR;
q->io_flags = 0;
if (sess == MSM_VIDC_DECODER)
q->ops = msm_vdec_get_vb2q_ops();
else if (sess == MSM_VIDC_ENCODER)
q->ops = msm_venc_get_vb2q_ops();
q->mem_ops = &msm_vidc_vb2_mem_ops;
q->drv_priv = inst;
return vb2_queue_init(q);
}
int msm_vidc_open(void *vidc_inst, int core_id, int session_type)
{
struct msm_vidc_inst *inst = (struct msm_vidc_inst *)vidc_inst;
struct msm_vidc_core *core = NULL;
unsigned long flags;
int rc = 0;
int i = 0;
if (core_id >= MSM_VIDC_CORES_MAX ||
session_type >= MSM_VIDC_MAX_DEVICES) {
pr_err("Invalid input, core_id = %d, session = %d\n",
core_id, session_type);
goto err_invalid_core;
}
core = get_vidc_core(core_id);
if (!core) {
pr_err("Failed to find core for core_id = %d\n", core_id);
goto err_invalid_core;
}
mutex_init(&inst->sync_lock);
spin_lock_init(&inst->lock);
inst->session_type = session_type;
INIT_LIST_HEAD(&inst->pendingq);
INIT_LIST_HEAD(&inst->internalbufs);
inst->state = MSM_VIDC_CORE_UNINIT_DONE;
inst->core = core;
for (i = SESSION_MSG_INDEX(SESSION_MSG_START);
i <= SESSION_MSG_INDEX(SESSION_MSG_END); i++) {
init_completion(&inst->completions[i]);
}
inst->mem_client = msm_smem_new_client(SMEM_ION);
if (!inst->mem_client) {
pr_err("Failed to create memory client\n");
goto fail_mem_client;
}
if (session_type == MSM_VIDC_DECODER) {
msm_vdec_inst_init(inst);
msm_vdec_ctrl_init(inst);
} else if (session_type == MSM_VIDC_ENCODER) {
msm_venc_inst_init(inst);
msm_venc_ctrl_init(inst);
}
rc = vb2_bufq_init(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
session_type);
if (rc) {
pr_err("Failed to initialize vb2 queue on capture port\n");
goto fail_init;
}
rc = vb2_bufq_init(inst, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
session_type);
if (rc) {
pr_err("Failed to initialize vb2 queue on capture port\n");
goto fail_init;
}
rc = msm_comm_try_state(inst, MSM_VIDC_CORE_INIT);
if (rc) {
pr_err("Failed to move video instance to init state\n");
goto fail_init;
}
spin_lock_irqsave(&core->lock, flags);
list_add_tail(&inst->list, &core->instances);
spin_unlock_irqrestore(&core->lock, flags);
return rc;
fail_init:
msm_smem_delete_client(inst->mem_client);
fail_mem_client:
kfree(inst);
inst = NULL;
err_invalid_core:
return rc;
}
static void cleanup_instance(struct msm_vidc_inst *inst)
{
unsigned long flags;
struct list_head *ptr, *next;
struct vb2_buf_entry *entry;
struct internal_buf *buf;
if (inst) {
spin_lock_irqsave(&inst->lock, flags);
if (!list_empty(&inst->pendingq)) {
list_for_each_safe(ptr, next, &inst->pendingq) {
entry = list_entry(ptr, struct vb2_buf_entry,
list);
list_del(&entry->list);
kfree(entry);
}
}
if (!list_empty(&inst->internalbufs)) {
list_for_each_safe(ptr, next, &inst->internalbufs) {
buf = list_entry(ptr, struct internal_buf,
list);
list_del(&buf->list);
msm_smem_free(inst->mem_client, buf->handle);
kfree(buf);
}
}
spin_unlock_irqrestore(&inst->lock, flags);
msm_smem_delete_client(inst->mem_client);
}
}
int msm_vidc_close(void *instance)
{
struct msm_vidc_inst *inst = instance;
struct msm_vidc_inst *temp;
struct msm_vidc_core *core;
struct list_head *ptr, *next;
int rc = 0;
core = inst->core;
mutex_lock(&core->sync_lock);
list_for_each_safe(ptr, next, &core->instances) {
temp = list_entry(ptr, struct msm_vidc_inst, list);
if (temp == inst)
list_del(&inst->list);
}
mutex_unlock(&core->sync_lock);
rc = msm_comm_try_state(inst, MSM_VIDC_CORE_UNINIT);
if (rc)
pr_err("Failed to move video instance to uninit state\n");
cleanup_instance(inst);
pr_debug("Closed the instance\n");
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,36 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _MSM_VIDC_COMMON_H_
#define _MSM_VIDC_COMMON_H_
#include "msm_vidc_internal.h"
struct vb2_buf_entry {
struct list_head list;
struct vb2_buffer *vb;
};
struct msm_vidc_core *get_vidc_core(int core_id);
const struct msm_vidc_format *msm_comm_get_pixel_fmt_index(
const struct msm_vidc_format fmt[], int size, int index, int fmt_type);
const struct msm_vidc_format *msm_comm_get_pixel_fmt_fourcc(
const struct msm_vidc_format fmt[], int size, int fourcc, int fmt_type);
struct vb2_queue *msm_comm_get_vb2q(
struct msm_vidc_inst *inst, enum v4l2_buf_type type);
int msm_comm_try_state(struct msm_vidc_inst *inst, int state);
int msm_comm_try_get_bufreqs(struct msm_vidc_inst *inst);
int msm_comm_set_scratch_buffers(struct msm_vidc_inst *inst);
int msm_comm_qbuf(struct vb2_buffer *vb);
#define IS_PRIV_CTRL(idx) (\
(V4L2_CTRL_ID2CLASS(idx) == V4L2_CTRL_CLASS_MPEG) && \
V4L2_CTRL_DRIVER_PRIV(idx))
#endif

View File

@@ -0,0 +1,171 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _MSM_VIDC_INTERNAL_H_
#define _MSM_VIDC_INTERNAL_H_
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/completion.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-event.h>
#include <media/v4l2-ctrls.h>
#include <media/videobuf2-core.h>
#include <media/msm_vidc.h>
#include "vidc_hal_api.h"
#define MSM_VIDC_DRV_NAME "msm_vidc_driver"
#define MSM_VIDC_VERSION KERNEL_VERSION(0, 0, 1);
#define MAX_DEBUGFS_NAME 50
#define DEFAULT_TIMEOUT 3
#define V4L2_EVENT_VIDC_BASE 10
#define SYS_MSG_START VIDC_EVENT_CHANGE
#define SYS_MSG_END SYS_DEBUG
#define SESSION_MSG_START SESSION_LOAD_RESOURCE_DONE
#define SESSION_MSG_END SESSION_PROPERTY_INFO
#define SYS_MSG_INDEX(__msg) (__msg - SYS_MSG_START)
#define SESSION_MSG_INDEX(__msg) (__msg - SESSION_MSG_START)
enum vidc_ports {
OUTPUT_PORT,
CAPTURE_PORT,
MAX_PORT_NUM
};
enum vidc_core_state {
VIDC_CORE_UNINIT = 0,
VIDC_CORE_INIT,
VIDC_CORE_INIT_DONE,
};
/*Donot change the enum values unless
* you know what you are doing*/
enum instance_state {
MSM_VIDC_CORE_UNINIT_DONE = 0x0001,
MSM_VIDC_CORE_INIT,
MSM_VIDC_CORE_INIT_DONE,
MSM_VIDC_OPEN,
MSM_VIDC_OPEN_DONE,
MSM_VIDC_LOAD_RESOURCES,
MSM_VIDC_LOAD_RESOURCES_DONE,
MSM_VIDC_START,
MSM_VIDC_START_DONE,
MSM_VIDC_STOP,
MSM_VIDC_STOP_DONE,
MSM_VIDC_RELEASE_RESOURCES,
MSM_VIDC_RELEASE_RESOURCES_DONE,
MSM_VIDC_CLOSE,
MSM_VIDC_CLOSE_DONE,
MSM_VIDC_CORE_UNINIT,
};
enum vidc_resposes_id {
MSM_VIDC_DECODER_FLUSH_DONE = 0x11,
MSM_VIDC_DECODER_EVENT_CHANGE,
};
struct buf_info {
struct list_head list;
struct vb2_buffer *buf;
};
struct internal_buf {
struct list_head list;
struct msm_smem *handle;
};
struct msm_vidc_format {
char name[64];
u8 description[32];
u32 fourcc;
int num_planes;
int type;
u32 (*get_frame_size)(int plane, u32 height, u32 width);
};
struct msm_vidc_drv {
spinlock_t lock;
struct list_head cores;
int num_cores;
struct dentry *debugfs_root;
};
struct msm_video_device {
int type;
struct video_device vdev;
};
struct msm_vidc_core {
struct list_head list;
struct mutex sync_lock;
int id;
void *device;
struct msm_video_device vdev[MSM_VIDC_MAX_DEVICES];
struct v4l2_device v4l2_dev;
spinlock_t lock;
struct list_head instances;
struct dentry *debugfs_root;
u32 base_addr;
u32 register_base;
u32 register_size;
u32 irq;
enum vidc_core_state state;
struct completion completions[SYS_MSG_END - SYS_MSG_START + 1];
};
struct msm_vidc_inst {
struct list_head list;
struct mutex sync_lock;
struct msm_vidc_core *core;
int session_type;
void *session;
u32 width;
u32 height;
int state;
const struct msm_vidc_format *fmts[MAX_PORT_NUM];
struct vb2_queue vb2_bufq[MAX_PORT_NUM];
spinlock_t lock;
struct list_head pendingq;
struct list_head internalbufs;
struct buffer_requirements buff_req;
void *mem_client;
struct v4l2_ctrl_handler ctrl_handler;
struct completion completions[SESSION_MSG_END - SESSION_MSG_START + 1];
struct v4l2_fh event_handler;
bool in_reconfig;
u32 reconfig_width;
u32 reconfig_height;
};
extern struct msm_vidc_drv *vidc_driver;
struct msm_vidc_ctrl {
u32 id;
char name[64];
enum v4l2_ctrl_type type;
s32 minimum;
s32 maximum;
s32 default_value;
u32 step;
u32 menu_skip_mask;
const char * const *qmenu;
};
void handle_cmd_response(enum command_response cmd, void *data);
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,975 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef __VIDC_HAL_API_H__
#define __VIDC_HAL_API_H__
#include <linux/types.h>
#define CONTAINS(__a, __sz, __t) ({\
int __rc = __t >= __a && \
__t < __a + __sz; \
__rc; \
})
#define OVERLAPS(__t, __tsz, __a, __asz) ({\
int __rc = __t <= __a && \
__t + __tsz >= __a + __asz; \
__rc; \
})
#define HAL_BUFFERFLAG_EOS 0x00000001
#define HAL_BUFFERFLAG_STARTTIME 0x00000002
#define HAL_BUFFERFLAG_DECODEONLY 0x00000004
#define HAL_BUFFERFLAG_DATACORRUPT 0x00000008
#define HAL_BUFFERFLAG_ENDOFFRAME 0x00000010
#define HAL_BUFFERFLAG_SYNCFRAME 0x00000020
#define HAL_BUFFERFLAG_EXTRADATA 0x00000040
#define HAL_BUFFERFLAG_CODECCONFIG 0x00000080
#define HAL_BUFFERFLAG_TIMESTAMPINVALID 0x00000100
#define HAL_BUFFERFLAG_READONLY 0x00000200
#define HAL_BUFFERFLAG_ENDOFSUBFRAME 0x00000400
enum vidc_status {
VIDC_ERR_NONE = 0x0,
VIDC_ERR_FAIL = 0x80000000,
VIDC_ERR_ALLOC_FAIL,
VIDC_ERR_ILLEGAL_OP,
VIDC_ERR_BAD_PARAM,
VIDC_ERR_BAD_HANDLE,
VIDC_ERR_NOT_SUPPORTED,
VIDC_ERR_BAD_STATE,
VIDC_ERR_MAX_CLIENT,
VIDC_ERR_IFRAME_EXPECTED,
VIDC_ERR_HW_FATAL,
VIDC_ERR_BITSTREAM_ERR,
VIDC_ERR_INDEX_NOMORE,
VIDC_ERR_SEQHDR_PARSE_FAIL,
VIDC_ERR_INSUFFICIENT_BUFFER,
VIDC_ERR_BAD_POWER_STATE,
VIDC_ERR_NO_VALID_SESSION,
VIDC_ERR_TIMEOUT,
VIDC_ERR_CMDQFULL,
VIDC_ERR_CLIENT_PRESENT = 0x90000001,
VIDC_ERR_CLIENT_FATAL,
VIDC_ERR_CMD_QUEUE_FULL,
VIDC_ERR_UNUSED = 0x10000000
};
enum hal_property {
HAL_CONFIG_FRAME_RATE = 0x04000001,
HAL_PARAM_UNCOMPRESSED_FORMAT_SELECT,
HAL_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO,
HAL_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO,
HAL_PARAM_EXTRA_DATA_HEADER_CONFIG,
HAL_PARAM_FRAME_SIZE,
HAL_CONFIG_REALTIME,
HAL_PARAM_BUFFER_COUNT_ACTUAL,
HAL_PARAM_NAL_STREAM_FORMAT_SELECT,
HAL_PARAM_VDEC_OUTPUT_ORDER,
HAL_PARAM_VDEC_PICTURE_TYPE_DECODE,
HAL_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO,
HAL_CONFIG_VDEC_POST_LOOP_DEBLOCKER,
HAL_PARAM_VDEC_MULTI_STREAM,
HAL_PARAM_VDEC_DISPLAY_PICTURE_BUFFER_COUNT,
HAL_PARAM_DIVX_FORMAT,
HAL_CONFIG_VDEC_MB_ERROR_MAP_REPORTING,
HAL_PARAM_VDEC_CONTINUE_DATA_TRANSFER,
HAL_CONFIG_VDEC_MB_ERROR_MAP,
HAL_CONFIG_VENC_REQUEST_IFRAME,
HAL_PARAM_VENC_MPEG4_SHORT_HEADER,
HAL_PARAM_VENC_MPEG4_AC_PREDICTION,
HAL_CONFIG_VENC_TARGET_BITRATE,
HAL_PARAM_PROFILE_LEVEL_CURRENT,
HAL_PARAM_VENC_H264_ENTROPY_CONTROL,
HAL_PARAM_VENC_RATE_CONTROL,
HAL_PARAM_VENC_MPEG4_TIME_RESOLUTION,
HAL_PARAM_VENC_MPEG4_HEADER_EXTENSION,
HAL_PARAM_VENC_H264_DEBLOCK_CONTROL,
HAL_PARAM_VENC_TEMPORAL_SPATIAL_TRADEOFF,
HAL_PARAM_VENC_SESSION_QP,
HAL_CONFIG_VENC_INTRA_PERIOD,
HAL_CONFIG_VENC_IDR_PERIOD,
HAL_CONFIG_VPE_OPERATIONS,
HAL_PARAM_VENC_INTRA_REFRESH,
HAL_PARAM_VENC_MULTI_SLICE_CONTROL,
HAL_CONFIG_VPE_DEINTERLACE,
HAL_SYS_DEBUG_CONFIG,
HAL_CONFIG_BUFFER_REQUIREMENTS,
HAL_CONFIG_PRIORITY,
HAL_CONFIG_BATCH_INFO,
HAL_PARAM_METADATA_PASS_THROUGH,
HAL_SYS_IDLE_INDICATOR,
HAL_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED,
HAL_PARAM_INTERLACE_FORMAT_SUPPORTED,
HAL_PARAM_CHROMA_SITE,
HAL_PARAM_PROPERTIES_SUPPORTED,
HAL_PARAM_PROFILE_LEVEL_SUPPORTED,
HAL_PARAM_CAPABILITY_SUPPORTED,
HAL_PARAM_NAL_STREAM_FORMAT_SUPPORTED,
HAL_PARAM_MULTI_VIEW_FORMAT,
HAL_PARAM_MAX_SEQUENCE_HEADER_SIZE,
HAL_PARAM_CODEC_SUPPORTED,
HAL_PARAM_VDEC_MULTI_VIEW_SELECT,
HAL_PARAM_VDEC_MB_QUANTIZATION,
HAL_PARAM_VDEC_NUM_CONCEALED_MB,
HAL_PARAM_VDEC_H264_ENTROPY_SWITCHING,
HAL_PARAM_VENC_SLICE_DELIVERY_MODE,
HAL_PARAM_VENC_MPEG4_DATA_PARTITIONING,
HAL_CONFIG_BUFFER_COUNT_ACTUAL,
HAL_CONFIG_VDEC_MULTI_STREAM,
HAL_PARAM_VENC_MULTI_SLICE_INFO,
HAL_CONFIG_VENC_TIMESTAMP_SCALE,
HAL_PARAM_VENC_LOW_LATENCY,
};
enum hal_domain {
HAL_VIDEO_DOMAIN_VPE,
HAL_VIDEO_DOMAIN_ENCODER,
HAL_VIDEO_DOMAIN_DECODER,
HAL_UNUSED_DOMAIN = 0x10000000,
};
enum hal_video_codec {
HAL_VIDEO_CODEC_UNKNOWN = 0x00000000,
HAL_VIDEO_CODEC_MVC = 0x00000001,
HAL_VIDEO_CODEC_H264 = 0x00000002,
HAL_VIDEO_CODEC_H263 = 0x00000004,
HAL_VIDEO_CODEC_MPEG1 = 0x00000008,
HAL_VIDEO_CODEC_MPEG2 = 0x00000010,
HAL_VIDEO_CODEC_MPEG4 = 0x00000020,
HAL_VIDEO_CODEC_DIVX_311 = 0x00000040,
HAL_VIDEO_CODEC_DIVX = 0x00000080,
HAL_VIDEO_CODEC_VC1 = 0x00000100,
HAL_VIDEO_CODEC_SPARK = 0x00000200,
HAL_VIDEO_CODEC_VP6 = 0x00000400,
HAL_VIDEO_CODEC_VP7 = 0x00000800,
HAL_VIDEO_CODEC_VP8 = 0x00001000,
HAL_UNUSED_CODEC = 0x10000000,
};
enum hal_h263_profile {
HAL_H263_PROFILE_BASELINE = 0x00000001,
HAL_H263_PROFILE_H320CODING = 0x00000002,
HAL_H263_PROFILE_BACKWARDCOMPATIBLE = 0x00000004,
HAL_H263_PROFILE_ISWV2 = 0x00000008,
HAL_H263_PROFILE_ISWV3 = 0x00000010,
HAL_H263_PROFILE_HIGHCOMPRESSION = 0x00000020,
HAL_H263_PROFILE_INTERNET = 0x00000040,
HAL_H263_PROFILE_INTERLACE = 0x00000080,
HAL_H263_PROFILE_HIGHLATENCY = 0x00000100,
HAL_UNUSED_H263_PROFILE = 0x10000000,
};
enum hal_h263_level {
HAL_H263_LEVEL_10 = 0x00000001,
HAL_H263_LEVEL_20 = 0x00000002,
HAL_H263_LEVEL_30 = 0x00000004,
HAL_H263_LEVEL_40 = 0x00000008,
HAL_H263_LEVEL_45 = 0x00000010,
HAL_H263_LEVEL_50 = 0x00000020,
HAL_H263_LEVEL_60 = 0x00000040,
HAL_H263_LEVEL_70 = 0x00000080,
HAL_UNUSED_H263_LEVEL = 0x10000000,
};
enum hal_mpeg2_profile {
HAL_MPEG2_PROFILE_SIMPLE = 0x00000001,
HAL_MPEG2_PROFILE_MAIN = 0x00000002,
HAL_MPEG2_PROFILE_422 = 0x00000004,
HAL_MPEG2_PROFILE_SNR = 0x00000008,
HAL_MPEG2_PROFILE_SPATIAL = 0x00000010,
HAL_MPEG2_PROFILE_HIGH = 0x00000020,
HAL_UNUSED_MPEG2_PROFILE = 0x10000000,
};
enum hal_mpeg2_level {
HAL_MPEG2_LEVEL_LL = 0x00000001,
HAL_MPEG2_LEVEL_ML = 0x00000002,
HAL_MPEG2_LEVEL_H14 = 0x00000004,
HAL_MPEG2_LEVEL_HL = 0x00000008,
HAL_UNUSED_MEPG2_LEVEL = 0x10000000,
};
enum hal_mpeg4_profile {
HAL_MPEG4_PROFILE_SIMPLE = 0x00000001,
HAL_MPEG4_PROFILE_SIMPLESCALABLE = 0x00000002,
HAL_MPEG4_PROFILE_CORE = 0x00000004,
HAL_MPEG4_PROFILE_MAIN = 0x00000008,
HAL_MPEG4_PROFILE_NBIT = 0x00000010,
HAL_MPEG4_PROFILE_SCALABLETEXTURE = 0x00000020,
HAL_MPEG4_PROFILE_SIMPLEFACE = 0x00000040,
HAL_MPEG4_PROFILE_SIMPLEFBA = 0x00000080,
HAL_MPEG4_PROFILE_BASICANIMATED = 0x00000100,
HAL_MPEG4_PROFILE_HYBRID = 0x00000200,
HAL_MPEG4_PROFILE_ADVANCEDREALTIME = 0x00000400,
HAL_MPEG4_PROFILE_CORESCALABLE = 0x00000800,
HAL_MPEG4_PROFILE_ADVANCEDCODING = 0x00001000,
HAL_MPEG4_PROFILE_ADVANCEDCORE = 0x00002000,
HAL_MPEG4_PROFILE_ADVANCEDSCALABLE = 0x00004000,
HAL_MPEG4_PROFILE_ADVANCEDSIMPLE = 0x00008000,
HAL_UNUSED_MPEG4_PROFILE = 0x10000000,
};
enum hal_mpeg4_level {
HAL_MPEG4_LEVEL_0 = 0x00000001,
HAL_MPEG4_LEVEL_0b = 0x00000002,
HAL_MPEG4_LEVEL_1 = 0x00000004,
HAL_MPEG4_LEVEL_2 = 0x00000008,
HAL_MPEG4_LEVEL_3 = 0x00000010,
HAL_MPEG4_LEVEL_4 = 0x00000020,
HAL_MPEG4_LEVEL_4a = 0x00000040,
HAL_MPEG4_LEVEL_5 = 0x00000080,
HAL_MPEG4_LEVEL_VENDOR_START_UNUSED = 0x7F000000,
HAL_MPEG4_LEVEL_6 = 0x7F000001,
HAL_MPEG4_LEVEL_7 = 0x7F000002,
HAL_MPEG4_LEVEL_8 = 0x7F000003,
HAL_MPEG4_LEVEL_9 = 0x7F000004,
HAL_MPEG4_LEVEL_3b = 0x7F000005,
HAL_UNUSED_MPEG4_LEVEL = 0x10000000,
};
enum hal_h264_profile {
HAL_H264_PROFILE_BASELINE = 0x00000001,
HAL_H264_PROFILE_MAIN = 0x00000002,
HAL_H264_PROFILE_EXTENDED = 0x00000004,
HAL_H264_PROFILE_HIGH = 0x00000008,
HAL_H264_PROFILE_HIGH10 = 0x00000010,
HAL_H264_PROFILE_HIGH422 = 0x00000020,
HAL_H264_PROFILE_HIGH444 = 0x00000040,
HAL_UNUSED_H264_PROFILE = 0x10000000,
};
enum hal_h264_level {
HAL_H264_LEVEL_1 = 0x00000001,
HAL_H264_LEVEL_1b = 0x00000002,
HAL_H264_LEVEL_11 = 0x00000004,
HAL_H264_LEVEL_12 = 0x00000008,
HAL_H264_LEVEL_13 = 0x00000010,
HAL_H264_LEVEL_2 = 0x00000020,
HAL_H264_LEVEL_21 = 0x00000040,
HAL_H264_LEVEL_22 = 0x00000080,
HAL_H264_LEVEL_3 = 0x00000100,
HAL_H264_LEVEL_31 = 0x00000200,
HAL_H264_LEVEL_32 = 0x00000400,
HAL_H264_LEVEL_4 = 0x00000800,
HAL_H264_LEVEL_41 = 0x00001000,
HAL_H264_LEVEL_42 = 0x00002000,
HAL_H264_LEVEL_5 = 0x00004000,
HAL_H264_LEVEL_51 = 0x00008000,
HAL_UNUSED_H264_LEVEL = 0x10000000,
};
enum hal_vpx_profile {
HAL_VPX_PROFILE_SIMPLE = 0x00000001,
HAL_VPX_PROFILE_ADVANCED = 0x00000002,
HAL_VPX_PROFILE_VERSION_0 = 0x00000004,
HAL_VPX_PROFILE_VERSION_1 = 0x00000008,
HAL_VPX_PROFILE_VERSION_2 = 0x00000010,
HAL_VPX_PROFILE_VERSION_3 = 0x00000020,
HAL_VPX_PROFILE_UNUSED = 0x10000000,
};
enum hal_vc1_profile {
HAL_VC1_PROFILE_SIMPLE = 0x00000001,
HAL_VC1_PROFILE_MAIN = 0x00000002,
HAL_VC1_PROFILE_ADVANCED = 0x00000004,
HAL_UNUSED_VC1_PROFILE = 0x10000000,
};
enum hal_vc1_level {
HAL_VC1_LEVEL_LOW = 0x00000001,
HAL_VC1_LEVEL_MEDIUM = 0x00000002,
HAL_VC1_LEVEL_HIGH = 0x00000004,
HAL_VC1_LEVEL_0 = 0x00000008,
HAL_VC1_LEVEL_1 = 0x00000010,
HAL_VC1_LEVEL_2 = 0x00000020,
HAL_VC1_LEVEL_3 = 0x00000040,
HAL_VC1_LEVEL_4 = 0x00000080,
HAL_UNUSED_VC1_LEVEL = 0x10000000,
};
enum hal_divx_format {
HAL_DIVX_FORMAT_4,
HAL_DIVX_FORMAT_5,
HAL_DIVX_FORMAT_6,
HAL_UNUSED_DIVX_FORMAT = 0x10000000,
};
enum hal_divx_profile {
HAL_DIVX_PROFILE_QMOBILE = 0x00000001,
HAL_DIVX_PROFILE_MOBILE = 0x00000002,
HAL_DIVX_PROFILE_MT = 0x00000004,
HAL_DIVX_PROFILE_HT = 0x00000008,
HAL_DIVX_PROFILE_HD = 0x00000010,
HAL_UNUSED_DIVX_PROFILE = 0x10000000,
};
enum hal_mvc_profile {
HAL_MVC_PROFILE_STEREO_HIGH = 0x00000001,
HAL_MVC_PROFILE_MV_HIGH = 0x00000002,
HAL_UNUSED_MVC_PROFILE = 0x10000000,
};
enum hal_mvc_level {
HAL_MVC_LEVEL_1 = 0x00000001,
HAL_MVC_LEVEL_1b = 0x00000002,
HAL_MVC_LEVEL_11 = 0x00000004,
HAL_MVC_LEVEL_12 = 0x00000008,
HAL_MVC_LEVEL_13 = 0x00000010,
HAL_MVC_LEVEL_2 = 0x00000020,
HAL_MVC_LEVEL_21 = 0x00000040,
HAL_MVC_LEVEL_22 = 0x00000080,
HAL_MVC_LEVEL_3 = 0x00000100,
HAL_MVC_LEVEL_31 = 0x00000200,
HAL_MVC_LEVEL_32 = 0x00000400,
HAL_MVC_LEVEL_4 = 0x00000800,
HAL_MVC_LEVEL_41 = 0x00001000,
HAL_MVC_LEVEL_42 = 0x00002000,
HAL_MVC_LEVEL_5 = 0x00004000,
HAL_MVC_LEVEL_51 = 0x00008000,
HAL_UNUSED_MVC_LEVEL = 0x10000000,
};
enum hal_buffer {
HAL_BUFFER_INPUT,
HAL_BUFFER_OUTPUT,
HAL_BUFFER_OUTPUT2,
HAL_BUFFER_EXTRADATA_INPUT,
HAL_BUFFER_EXTRADATA_OUTPUT,
HAL_BUFFER_EXTRADATA_OUTPUT2,
HAL_BUFFER_INTERNAL_SCRATCH,
HAL_BUFFER_INTERNAL_PERSIST,
HAL_UNUSED_BUFFER = 0x10000000,
};
struct hal_frame_rate {
enum hal_buffer buffer_type;
u32 frame_rate;
};
enum hal_uncompressed_format {
HAL_COLOR_FORMAT_MONOCHROME,
HAL_COLOR_FORMAT_NV12,
HAL_COLOR_FORMAT_NV21,
HAL_COLOR_FORMAT_NV12_4x4TILE,
HAL_COLOR_FORMAT_NV21_4x4TILE,
HAL_COLOR_FORMAT_YUYV,
HAL_COLOR_FORMAT_YVYU,
HAL_COLOR_FORMAT_UYVY,
HAL_COLOR_FORMAT_VYUY,
HAL_COLOR_FORMAT_RGB565,
HAL_COLOR_FORMAT_BGR565,
HAL_COLOR_FORMAT_RGB888,
HAL_COLOR_FORMAT_BGR888,
HAL_UNUSED_COLOR = 0x10000000,
};
struct hal_uncompressed_format_select {
enum hal_buffer buffer_type;
enum hal_uncompressed_format format;
};
struct hal_uncompressed_plane_actual {
int actual_stride;
u32 actual_plane_buffer_height;
};
struct hal_uncompressed_plane_actual_info {
enum hal_buffer buffer_type;
u32 num_planes;
struct hal_uncompressed_plane_actual rg_plane_format[1];
};
struct hal_uncompressed_plane_constraints {
u32 stride_multiples;
u32 max_stride;
u32 min_plane_buffer_height_multiple;
u32 buffer_alignment;
};
struct hal_uncompressed_plane_actual_constraints_info {
enum hal_buffer buffer_type;
u32 num_planes;
struct hal_uncompressed_plane_constraints rg_plane_format[1];
};
struct hal_extra_data_header_config {
u32 type;
enum hal_buffer buffer_type;
u32 version;
u32 port_index;
u32 client_extradata_id;
};
struct hal_frame_size {
enum hal_buffer buffer_type;
u32 width;
u32 height;
};
struct hal_enable {
u32 enable;
};
struct hal_buffer_count_actual {
enum hal_buffer buffer_type;
u32 buffer_count_actual;
};
enum hal_nal_stream_format {
HAL_NAL_FORMAT_STARTCODES = 0x00000001,
HAL_NAL_FORMAT_ONE_NAL_PER_BUFFER = 0x00000002,
HAL_NAL_FORMAT_ONE_BYTE_LENGTH = 0x00000004,
HAL_NAL_FORMAT_TWO_BYTE_LENGTH = 0x00000008,
HAL_NAL_FORMAT_FOUR_BYTE_LENGTH = 0x00000010,
};
enum hal_output_order {
HAL_OUTPUT_ORDER_DISPLAY,
HAL_OUTPUT_ORDER_DECODE,
HAL_UNUSED_OUTPUT = 0x10000000,
};
enum hal_picture {
HAL_PICTURE_I = 0x01,
HAL_PICTURE_P = 0x02,
HAL_PICTURE_B = 0x04,
HAL_PICTURE_IDR = 0x7F001000,
HAL_FRAME_NOTCODED = 0x7F002000,
HAL_FRAME_YUV = 0x7F004000,
HAL_UNUSED_PICT = 0x10000000,
};
struct hal_enable_picture {
u32 picture_type;
};
struct hal_multi_stream {
enum hal_buffer buffer_type;
u32 enable;
u32 width;
u32 height;
};
struct hal_display_picture_buffer_count {
u32 enable;
u32 count;
};
struct hal_mb_error_map {
u32 error_map_size;
u8 rg_error_map[1];
};
struct hal_request_iframe {
u32 enable;
};
struct hal_bitrate {
u32 bit_rate;
};
struct hal_profile_level {
u32 profile;
u32 level;
};
/*
struct hal_profile_level_range {
u32 profile;
u32 min_level;
u32 max_level;
}
struct hal_profile_level_supported {
u32 profile_count;
struct hal_profile_level_range profile_level[1];
};
*/
enum hal_h264_entropy {
HAL_H264_ENTROPY_CAVLC,
HAL_H264_ENTROPY_CABAC,
HAL_UNUSED_ENTROPY = 0x10000000,
};
enum hal_h264_cabac_model {
HAL_H264_CABAC_MODEL_0,
HAL_H264_CABAC_MODEL_1,
HAL_H264_CABAC_MODEL_2,
HAL_UNUSED_CABAC = 0x10000000,
};
struct hal_h264_entropy_control {
enum hal_h264_entropy entropy_mode;
enum hal_h264_cabac_model cabac_model;
};
enum hal_rate_control {
HAL_RATE_CONTROL_OFF,
HAL_RATE_CONTROL_VBR_VFR,
HAL_RATE_CONTROL_VBR_CFR,
HAL_RATE_CONTROL_CBR_VFR,
HAL_RATE_CONTROL_CBR_CFR,
HAL_UNUSED_RC = 0x10000000,
};
struct hal_mpeg4_time_resolution {
u32 time_increment_resolution;
};
struct hal_mpeg4_header_extension {
u32 header_extension;
};
enum hal_h264_db_mode {
HAL_H264_DB_MODE_DISABLE,
HAL_H264_DB_MODE_SKIP_SLICE_BOUNDARY,
HAL_H264_DB_MODE_ALL_BOUNDARY,
HAL_UNUSED_H264_DB = 0x10000000,
};
struct hal_h264_db_control {
enum hal_h264_db_mode mode;
int slice_alpha_offset;
int slicebeta_offset;
};
struct hal_temporal_spatial_tradeoff {
u32 ts_factor;
};
struct hal_quantization {
u32 qpi;
u32 qpp;
u32 qpb;
};
struct hal_intra_period {
u32 pframes;
u32 bframes;
};
struct hal_idr_period {
u32 idr_period;
};
enum hal_rotate {
HAL_ROTATE_NONE,
HAL_ROTATE_90,
HAL_ROTATE_180,
HAL_ROTATE_270,
HAL_UNUSED_ROTATE = 0x10000000,
};
enum hal_flip {
HAL_FLIP_NONE,
HAL_FLIP_HORIZONTAL,
HAL_FLIP_VERTICAL,
HAL_UNUSED_FLIP = 0x10000000,
};
struct hal_operations {
enum hal_rotate rotate;
enum hal_flip flip;
};
enum hal_intra_refresh_mode {
HAL_INTRA_REFRESH_NONE,
HAL_INTRA_REFRESH_CYCLIC,
HAL_INTRA_REFRESH_ADAPTIVE,
HAL_INTRA_REFRESH_CYCLIC_ADAPTIVE,
HAL_INTRA_REFRESH_RANDOM,
HAL_UNUSED_INTRA = 0x10000000,
};
struct hal_intra_refresh {
enum hal_intra_refresh_mode mode;
u32 air_mbs;
u32 air_ref;
u32 cir_mbs;
};
enum hal_multi_slice {
HAL_MULTI_SLICE_OFF,
HAL_MULTI_SLICE_BY_MB_COUNT,
HAL_MULTI_SLICE_BY_BYTE_COUNT,
HAL_MULTI_SLICE_GOB,
HAL_UNUSED_SLICE = 0x10000000,
};
struct hal_multi_slice_control {
enum hal_multi_slice multi_slice;
u32 slice_size;
};
struct hal_debug_config {
u32 debug_config;
};
struct hal_buffer_requirements {
enum hal_buffer buffer_type;
u32 buffer_size;
u32 buffer_region_size;
u32 buffer_hold_count;
u32 buffer_count_min;
u32 buffer_count_actual;
u32 contiguous;
u32 buffer_alignment;
};
enum hal_priority {/* Priority increases with number */
HAL_PRIORITY_LOW = 10,
HAL_PRIOIRTY_MEDIUM = 20,
HAL_PRIORITY_HIGH = 30,
HAL_UNUSED_PRIORITY = 0x10000000,
};
struct hal_batch_info {
u32 input_batch_count;
u32 output_batch_count;
};
struct hal_metadata_pass_through {
u32 enable;
u32 size;
};
struct hal_uncompressed_format_supported {
enum hal_buffer buffer_type;
u32 format_entries;
u32 rg_format_info[1];
};
enum hal_interlace_format {
HAL_INTERLACE_FRAME_PROGRESSIVE = 0x01,
HAL_INTERLACE_INTERLEAVE_FRAME_TOPFIELDFIRST = 0x02,
HAL_INTERLACE_INTERLEAVE_FRAME_BOTTOMFIELDFIRST = 0x04,
HAL_INTERLACE_FRAME_TOPFIELDFIRST = 0x08,
HAL_INTERLACE_FRAME_BOTTOMFIELDFIRST = 0x10,
HAL_UNUSED_INTERLACE = 0x10000000,
};
struct hal_interlace_format_supported {
enum hal_buffer buffer_type;
enum hal_interlace_format format;
};
enum hal_chroma_site {
HAL_CHROMA_SITE_0,
HAL_CHROMA_SITE_1,
HAL_UNUSED_CHROMA = 0x10000000,
};
struct hal_properties_supported {
u32 num_properties;
u32 rg_properties[1];
};
enum hal_capability {
HAL_CAPABILITY_FRAME_WIDTH,
HAL_CAPABILITY_FRAME_HEIGHT,
HAL_CAPABILITY_MBS_PER_FRAME,
HAL_CAPABILITY_MBS_PER_SECOND,
HAL_CAPABILITY_FRAMERATE,
HAL_CAPABILITY_SCALE_X,
HAL_CAPABILITY_SCALE_Y,
HAL_CAPABILITY_BITRATE,
HAL_UNUSED_CAPABILITY = 0x10000000,
};
struct hal_capability_supported {
enum hal_capability capability_type;
u32 min;
u32 max;
u32 step_size;
};
struct hal_capability_supported_info {
u32 num_capabilities;
struct hal_capability_supported rg_data[1];
};
struct hal_nal_stream_format_supported {
u32 nal_stream_format_supported;
};
struct hal_multi_view_format {
u32 views;
u32 rg_view_order[1];
};
struct hal_seq_header_info {
u32 nax_header_len;
};
struct hal_codec_supported {
u32 decoder_codec_supported;
u32 encoder_codec_supported;
};
struct hal_multi_view_select {
u32 view_index;
};
struct hal_timestamp_scale {
u32 time_stamp_scale;
};
enum vidc_resource_id {
VIDC_RESOURCE_OCMEM = 0x00000001,
VIDC_UNUSED_RESORUCE = 0x10000000,
};
struct vidc_resource_hdr {
enum vidc_resource_id resource_id;
u32 resource_handle;
u32 size;
};
struct vidc_buffer_addr_info {
enum hal_buffer buffer_type;
u32 buffer_size;
u32 num_buffers;
u32 align_device_addr;
u32 extradata_size;
u32 extradata_addr;
};
struct vidc_frame_plane_config {
u32 left;
u32 top;
u32 width;
u32 height;
u32 stride;
u32 scan_lines;
};
struct vidc_uncompressed_frame_config {
struct vidc_frame_plane_config luma_plane;
struct vidc_frame_plane_config chroma_plane;
};
struct vidc_frame_data {
enum hal_buffer buffer_type;
u32 device_addr;
u32 extradata_addr;
int64_t timestamp;
u32 flags;
u32 offset;
u32 alloc_len;
u32 filled_len;
u32 mark_target;
u32 mark_data;
u32 clnt_data;
};
struct vidc_seq_hdr {
u8 *seq_hdr;
u32 seq_hdr_len;
};
enum hal_flush {
HAL_FLUSH_INPUT,
HAL_FLUSH_OUTPUT,
HAL_FLUSH_OUTPUT2,
HAL_FLUSH_ALL,
HAL_UNUSED_FLUSH = 0x10000000,
};
/* HAL Response */
enum command_response {
/* SYSTEM COMMANDS_DONE*/
VIDC_EVENT_CHANGE,
SYS_INIT_DONE,
SET_RESOURCE_DONE,
RELEASE_RESOURCE_DONE,
PING_ACK_DONE,
PC_PREP_DONE,
SYS_IDLE,
SYS_DEBUG,
/* SESSION COMMANDS_DONE */
SESSION_LOAD_RESOURCE_DONE,
SESSION_INIT_DONE,
SESSION_END_DONE,
SESSION_ABORT_DONE,
SESSION_START_DONE,
SESSION_STOP_DONE,
SESSION_ETB_DONE,
SESSION_FTB_DONE,
SESSION_FLUSH_DONE,
SESSION_SUSPEND_DONE,
SESSION_RESUME_DONE,
SESSION_SET_PROP_DONE,
SESSION_GET_PROP_DONE,
SESSION_PARSE_SEQ_HDR_DONE,
SESSION_GET_SEQ_HDR_DONE,
SESSION_RELEASE_BUFFER_DONE,
SESSION_RELEASE_RESOURCE_DONE,
SESSION_PROPERTY_INFO,
RESPONSE_UNUSED = 0x10000000,
};
/* Command Callback structure */
struct msm_vidc_cb_cmd_done {
u32 device_id;
u32 session_id;
u32 status;
u32 size;
void *data;
};
struct msm_vidc_cb_event {
u32 device_id;
u32 session_id;
u32 status;
u32 height;
u32 width;
};
/* Data callback structure */
struct vidc_hal_ebd {
u32 timestamp_hi;
u32 timestamp_lo;
u32 flags;
u32 mark_target;
u32 mark_data;
u32 stats;
u32 offset;
u32 alloc_len;
u32 filled_len;
enum hal_picture picture_type;
u8 *packet_buffer;
u8 *extra_data_buffer;
};
struct vidc_hal_fbd {
u32 stream_id;
u32 view_id;
u32 timestamp_hi;
u32 timestamp_lo;
u32 flags1;
u32 mark_target;
u32 mark_data;
u32 stats;
u32 alloc_len1;
u32 filled_len1;
u32 offset1;
u32 frame_width;
u32 frame_height;
u32 start_xCoord;
u32 start_yCoord;
u32 input_tag;
u32 input_tag1;
enum hal_picture picture_type;
u8 *packet_buffer1;
u8 *extra_data_buffer;
u32 flags2;
u32 alloc_len2;
u32 filled_len2;
u32 offset2;
u8 *packet_buffer2;
u32 flags3;
u32 alloc_len3;
u32 filled_len3;
u32 offset3;
u8 *packet_buffer3;
enum hal_buffer buffer_type;
};
struct msm_vidc_cb_data_done {
u32 device_id;
u32 session_id;
u32 status;
u32 size;
void *clnt_data;
union {
struct vidc_hal_ebd input_done;
struct vidc_hal_fbd output_done;
};
};
struct vidc_hal_sys_init_done {
u32 enc_codec_supported;
u32 dec_codec_supported;
};
struct vidc_hal_session_init_done {
struct hal_capability_supported width;
struct hal_capability_supported height;
struct hal_capability_supported mbs_per_frame;
struct hal_capability_supported mbs_per_sec;
struct hal_capability_supported frame_rate;
struct hal_capability_supported scale_x;
struct hal_capability_supported scale_y;
struct hal_capability_supported bitrate;
struct hal_uncompressed_format_supported uncomp_format;
struct hal_interlace_format_supported HAL_format;
struct hal_nal_stream_format_supported nal_stream_format;
/* struct hal_profile_level_supported profile_level;
// allocate and released memory for above. */
struct hal_intra_refresh intra_refresh;
struct hal_seq_header_info seq_hdr_info;
};
struct buffer_requirements {
struct hal_buffer_requirements buffer[8];
};
/* VIDC_HAL CORE API's */
int vidc_hal_core_init(void *device);
int vidc_hal_core_release(void *device);
int vidc_hal_core_pc_prep(void *device);
int vidc_hal_core_set_resource(void *device,
struct vidc_resource_hdr *resource_hdr, void *resource_value);
int vidc_hal_core_release_resource(void *device,
struct vidc_resource_hdr *resource_hdr);
int vidc_hal_core_ping(void *device);
/* VIDC_HAL SESSION API's */
void *vidc_hal_session_init(void *device, u32 session_id,
enum hal_domain session_type, enum hal_video_codec codec_type);
int vidc_hal_session_end(void *session);
int vidc_hal_session_abort(void *session);
int vidc_hal_session_set_buffers(void *sess,
struct vidc_buffer_addr_info *buffer_info);
int vidc_hal_session_release_buffers(void *sess,
struct vidc_buffer_addr_info *buffer_info);
int vidc_hal_session_load_res(void *sess);
int vidc_hal_session_release_res(void *sess);
int vidc_hal_session_start(void *sess);
int vidc_hal_session_stop(void *sess);
int vidc_hal_session_suspend(void *sess);
int vidc_hal_session_resume(void *sess);
int vidc_hal_session_etb(void *sess,
struct vidc_frame_data *input_frame);
int vidc_hal_session_ftb(void *sess,
struct vidc_frame_data *output_frame);
int vidc_hal_session_parse_seq_hdr(void *sess,
struct vidc_seq_hdr *seq_hdr);
int vidc_hal_session_get_seq_hdr(void *sess,
struct vidc_seq_hdr *seq_hdr);
int vidc_hal_session_get_buf_req(void *sess);
int vidc_hal_session_flush(void *sess, enum hal_flush flush_mode);
int vidc_hal_session_set_property(void *sess, enum hal_property ptype,
void *pdata);
int vidc_hal_session_get_property(void *sess, enum hal_property ptype,
void *pdata);
void *vidc_hal_add_device(u32 device_id, u32 base_addr,
u32 reg_base, u32 reg_size, u32 irq,
void (*callback) (enum command_response cmd, void *data));
void vidc_hal_delete_device(void *device);
#endif /*__VIDC_HAL_API_H__ */

View File

@@ -0,0 +1,784 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/slab.h>
#include <linux/list.h>
#include "vidc_hal.h"
static enum vidc_status vidc_map_hal_err_status(enum HFI_ERROR hfi_err)
{
enum vidc_status vidc_err;
switch (hfi_err) {
case HFI_ERR_NONE:
case HFI_ERR_SESSION_SAME_STATE_OPERATION:
vidc_err = VIDC_ERR_NONE;
break;
case HFI_ERR_SYS_FATAL:
vidc_err = VIDC_ERR_HW_FATAL;
break;
case HFI_ERR_SYS_VERSION_MISMATCH:
case HFI_ERR_SYS_INVALID_PARAMETER:
case HFI_ERR_SYS_SESSION_ID_OUT_OF_RANGE:
case HFI_ERR_SESSION_INVALID_PARAMETER:
case HFI_ERR_SESSION_INVALID_SESSION_ID:
case HFI_ERR_SESSION_INVALID_STREAM_ID:
vidc_err = VIDC_ERR_BAD_PARAM;
break;
case HFI_ERR_SYS_INSUFFICIENT_RESOURCES:
case HFI_ERR_SYS_UNSUPPORTED_DOMAIN:
case HFI_ERR_SYS_UNSUPPORTED_CODEC:
case HFI_ERR_SESSION_UNSUPPORTED_PROPERTY:
case HFI_ERR_SESSION_UNSUPPORTED_SETTING:
case HFI_ERR_SESSION_INSUFFICIENT_RESOURCES:
vidc_err = VIDC_ERR_NOT_SUPPORTED;
break;
case HFI_ERR_SYS_MAX_SESSIONS_REACHED:
vidc_err = VIDC_ERR_MAX_CLIENT;
break;
case HFI_ERR_SYS_SESSION_IN_USE:
vidc_err = VIDC_ERR_CLIENT_PRESENT;
break;
case HFI_ERR_SESSION_FATAL:
vidc_err = VIDC_ERR_CLIENT_FATAL;
break;
case HFI_ERR_SESSION_BAD_POINTER:
vidc_err = VIDC_ERR_BAD_PARAM;
break;
case HFI_ERR_SESSION_INCORRECT_STATE_OPERATION:
vidc_err = VIDC_ERR_BAD_STATE;
break;
case HFI_ERR_SESSION_STREAM_CORRUPT:
case HFI_ERR_SESSION_STREAM_CORRUPT_OUTPUT_STALLED:
vidc_err = VIDC_ERR_BITSTREAM_ERR;
break;
case HFI_ERR_SESSION_SYNC_FRAME_NOT_DETECTED:
vidc_err = VIDC_ERR_IFRAME_EXPECTED;
break;
case HFI_ERR_SYS_UNKNOWN:
case HFI_ERR_SESSION_UNKNOWN:
case HFI_ERR_SESSION_EMPTY_BUFFER_DONE_OUTPUT_PENDING:
default:
vidc_err = VIDC_ERR_FAIL;
break;
}
return vidc_err;
}
void hal_process_sess_evt_seq_changed(struct hal_device *device,
struct hfi_msg_event_notify_packet *pkt)
{
struct msm_vidc_cb_cmd_done cmd_done;
struct msm_vidc_cb_event event_notify;
int num_properties_changed;
struct hfi_frame_size frame_sz;
u8 *data_ptr;
enum HFI_PROPERTY prop_id;
HAL_MSG_LOW("RECEIVED:EVENT_NOTIFY");
if (sizeof(struct hfi_msg_event_notify_packet)
> pkt->size) {
HAL_MSG_ERROR("hal_process_session_init_done:bad_pkt_size");
return;
}
memset(&cmd_done, 0, sizeof(struct msm_vidc_cb_cmd_done));
memset(&event_notify, 0, sizeof(struct
msm_vidc_cb_event));
cmd_done.device_id = device->device_id;
cmd_done.session_id = ((struct hal_session *) pkt->session_id)->
session_id;
cmd_done.status = VIDC_ERR_NONE;
cmd_done.size = sizeof(struct msm_vidc_cb_event);
num_properties_changed = pkt->event_data2;
if (num_properties_changed) {
data_ptr = (u8 *) &pkt->rg_ext_event_data[0];
do {
prop_id = (enum HFI_PROPERTY) *((u32 *)data_ptr);
switch (prop_id) {
case HFI_PROPERTY_PARAM_FRAME_SIZE:
frame_sz.buffer =
(enum HFI_BUFFER)
*((((u32 *)data_ptr)+1));
frame_sz.width =
event_notify.width =
*((((u32 *)data_ptr)+2));
frame_sz.height =
event_notify.height =
*((((u32 *)data_ptr)+3));
data_ptr += 4;
break;
default:
break;
}
num_properties_changed--;
} while (num_properties_changed > 0);
}
cmd_done.data = &event_notify;
device->callback(VIDC_EVENT_CHANGE, &cmd_done);
}
static void hal_process_event_notify(struct hal_device *device,
struct hfi_msg_event_notify_packet *pkt)
{
HAL_MSG_LOW("RECVD:EVENT_NOTIFY");
if (!device || !pkt ||
pkt->size < sizeof(struct hfi_msg_event_notify_packet)) {
HAL_MSG_ERROR("Invalid Params in %s", __func__);
return;
}
switch (pkt->event_id) {
case HFI_EVENT_SYS_ERROR:
HAL_MSG_INFO("HFI_EVENT_SYS_ERROR");
break;
case HFI_EVENT_SESSION_ERROR:
HAL_MSG_INFO("HFI_EVENT_SESSION_ERROR");
break;
case HFI_EVENT_SESSION_SEQUENCE_CHANGED:
HAL_MSG_INFO("HFI_EVENT_SESSION_SEQUENCE_CHANGED");
hal_process_sess_evt_seq_changed(device, pkt);
break;
case HFI_EVENT_SESSION_PROPERTY_CHANGED:
HAL_MSG_INFO("HFI_EVENT_SESSION_PROPERTY_CHANGED");
break;
default:
HAL_MSG_INFO("hal_process_event_notify:unkown_event_id");
break;
}
}
static void hal_process_sys_init_done(struct hal_device *device,
struct hfi_msg_sys_init_done_packet *pkt)
{
struct msm_vidc_cb_cmd_done cmd_done;
struct vidc_hal_sys_init_done sys_init_done;
u32 rem_bytes, bytes_read = 0, num_properties;
u8 *data_ptr;
enum HFI_PROPERTY prop_id;
enum vidc_status status = VIDC_ERR_NONE;
HAL_MSG_LOW("RECEIVED:SYS_INIT_DONE");
if (sizeof(struct hfi_msg_sys_init_done_packet) > pkt->size) {
HAL_MSG_ERROR("hal_process_sys_init_done:bad_pkt_size: %d",
pkt->size);
return;
}
status = vidc_map_hal_err_status((u32)pkt->error_type);
if (!status) {
if (pkt->num_properties == 0) {
HAL_MSG_ERROR("hal_process_sys_init_done:"
"no_properties");
status = VIDC_ERR_FAIL;
goto err_no_prop;
}
rem_bytes = pkt->size - sizeof(struct
hfi_msg_sys_init_done_packet) + sizeof(u32);
if (rem_bytes == 0) {
HAL_MSG_ERROR("hal_process_sys_init_done:"
"missing_prop_info");
status = VIDC_ERR_FAIL;
goto err_no_prop;
}
memset(&cmd_done, 0, sizeof(struct msm_vidc_cb_cmd_done));
memset(&sys_init_done, 0, sizeof(struct
vidc_hal_sys_init_done));
data_ptr = (u8 *) &pkt->rg_property_data[0];
num_properties = pkt->num_properties;
while ((num_properties != 0) && (rem_bytes >= sizeof(u32))) {
prop_id = (enum HFI_PROPERTY) *((u32 *)data_ptr);
data_ptr = data_ptr + 4;
switch (prop_id) {
case HFI_PROPERTY_PARAM_CODEC_SUPPORTED:
{
struct hfi_codec_supported *prop =
(struct hfi_codec_supported *) data_ptr;
if (rem_bytes < sizeof(struct
hfi_codec_supported)) {
status = VIDC_ERR_BAD_PARAM;
break;
}
sys_init_done.dec_codec_supported =
prop->decoder_codec_supported;
sys_init_done.enc_codec_supported =
prop->encoder_codec_supported;
break;
}
default:
HAL_MSG_ERROR("hal_process_sys_init_done:"
"bad_prop_id");
status = VIDC_ERR_BAD_PARAM;
break;
}
if (!status) {
rem_bytes -= bytes_read;
data_ptr += bytes_read;
num_properties--;
}
}
}
err_no_prop:
cmd_done.device_id = device->device_id;
cmd_done.session_id = 0;
cmd_done.status = (u32) status;
cmd_done.size = sizeof(struct vidc_hal_sys_init_done);
cmd_done.data = (void *) &sys_init_done;
device->callback(SYS_INIT_DONE, &cmd_done);
}
enum vidc_status vidc_hal_process_sess_init_done_prop_read(
struct hfi_msg_sys_session_init_done_packet *pkt,
struct msm_vidc_cb_cmd_done *cmddone)
{
return VIDC_ERR_NONE;
}
static void hal_process_sess_get_prop_buf_req(
struct hfi_msg_session_property_info_packet *prop,
struct buffer_requirements *buffreq)
{
struct hfi_buffer_requirements *hfi_buf_req;
u32 req_bytes;
enum vidc_status rc = VIDC_ERR_NONE;
HAL_MSG_LOW("Entered %s", __func__);
req_bytes = prop->size - sizeof(
struct hfi_msg_session_property_info_packet);
if (req_bytes == 0 || (req_bytes % sizeof(
struct hfi_buffer_requirements))) {
HAL_MSG_ERROR("hal_process_sess_get_prop_buf_req:bad_pkt_size:"
" %d", req_bytes);
return;
}
hfi_buf_req = (struct hfi_buffer_requirements *)
&prop->rg_property_data[1];
while (req_bytes != 0) {
if ((hfi_buf_req->buffer_count_min > hfi_buf_req->
buffer_count_actual)
|| (hfi_buf_req->buffer_alignment == 0)
|| (hfi_buf_req->buffer_size == 0)) {
HAL_MSG_ERROR("hal_process_sess_get_prop_buf_req:"
"bad_buf_req");
rc = VIDC_ERR_FAIL;
}
HAL_MSG_LOW("got buffer requirements for: %d",
hfi_buf_req->buffer);
switch (hfi_buf_req->buffer) {
case HFI_BUFFER_INPUT:
memcpy(&buffreq->buffer[0], hfi_buf_req,
sizeof(struct hfi_buffer_requirements));
buffreq->buffer[0].buffer_type = HAL_BUFFER_INPUT;
break;
case HFI_BUFFER_OUTPUT:
memcpy(&buffreq->buffer[1], hfi_buf_req,
sizeof(struct hfi_buffer_requirements));
buffreq->buffer[1].buffer_type = HAL_BUFFER_OUTPUT;
break;
case HFI_BUFFER_OUTPUT2:
memcpy(&buffreq->buffer[2], hfi_buf_req,
sizeof(struct hfi_buffer_requirements));
buffreq->buffer[2].buffer_type = HAL_BUFFER_OUTPUT2;
break;
case HFI_BUFFER_EXTRADATA_INPUT:
memcpy(&buffreq->buffer[3], hfi_buf_req,
sizeof(struct hfi_buffer_requirements));
buffreq->buffer[3].buffer_type =
HAL_BUFFER_EXTRADATA_INPUT;
break;
case HFI_BUFFER_EXTRADATA_OUTPUT:
memcpy(&buffreq->buffer[4], hfi_buf_req,
sizeof(struct hfi_buffer_requirements));
buffreq->buffer[4].buffer_type =
HAL_BUFFER_EXTRADATA_OUTPUT;
break;
case HFI_BUFFER_EXTRADATA_OUTPUT2:
memcpy(&buffreq->buffer[5], hfi_buf_req,
sizeof(struct hfi_buffer_requirements));
buffreq->buffer[5].buffer_type =
HAL_BUFFER_EXTRADATA_OUTPUT2;
break;
case HFI_BUFFER_INTERNAL_SCRATCH:
memcpy(&buffreq->buffer[6], hfi_buf_req,
sizeof(struct hfi_buffer_requirements));
buffreq->buffer[6].buffer_type =
HAL_BUFFER_INTERNAL_SCRATCH;
break;
case HFI_BUFFER_INTERNAL_PERSIST:
memcpy(&buffreq->buffer[7], hfi_buf_req,
sizeof(struct hfi_buffer_requirements));
buffreq->buffer[7].buffer_type =
HAL_BUFFER_INTERNAL_PERSIST;
break;
default:
HAL_MSG_ERROR("hal_process_sess_get_prop_buf_req:"
"bad_buffer_type: %d", hfi_buf_req->buffer);
break;
}
req_bytes -= sizeof(struct hfi_buffer_requirements);
hfi_buf_req++;
}
}
static void hal_process_session_prop_info(struct hal_device *device,
struct hfi_msg_session_property_info_packet *pkt)
{
struct msm_vidc_cb_cmd_done cmd_done;
struct buffer_requirements buff_req;
HAL_MSG_INFO("Received SESSION_PROPERTY_INFO");
if (pkt->size < sizeof(struct hfi_msg_session_property_info_packet)) {
HAL_MSG_ERROR("hal_process_session_prop_info:bad_pkt_size");
return;
}
if (pkt->num_properties == 0) {
HAL_MSG_ERROR("hal_process_session_prop_info:no_properties");
return;
}
memset(&cmd_done, 0, sizeof(struct msm_vidc_cb_cmd_done));
memset(&buff_req, 0, sizeof(struct buffer_requirements));
switch (pkt->rg_property_data[0]) {
case HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS:
hal_process_sess_get_prop_buf_req(pkt, &buff_req);
cmd_done.device_id = device->device_id;
cmd_done.session_id =
((struct hal_session *) pkt->session_id)->session_id;
cmd_done.status = VIDC_ERR_NONE;
cmd_done.data = &buff_req;
cmd_done.size = sizeof(struct buffer_requirements);
device->callback(SESSION_PROPERTY_INFO, &cmd_done);
break;
default:
HAL_MSG_ERROR("hal_process_session_prop_info:"
"unknown_prop_id: %d",
pkt->rg_property_data[0]);
break;
}
}
static void hal_process_session_init_done(struct hal_device *device,
struct hfi_msg_sys_session_init_done_packet *pkt)
{
struct msm_vidc_cb_cmd_done cmd_done;
struct vidc_hal_session_init_done session_init_done;
HAL_MSG_LOW("RECEIVED:SESSION_INIT_DONE");
if (sizeof(struct hfi_msg_sys_session_init_done_packet)
> pkt->size) {
HAL_MSG_ERROR("hal_process_session_init_done:bad_pkt_size");
return;
}
memset(&cmd_done, 0, sizeof(struct msm_vidc_cb_cmd_done));
memset(&session_init_done, 0, sizeof(struct
vidc_hal_session_init_done));
cmd_done.device_id = device->device_id;
cmd_done.session_id =
((struct hal_session *) pkt->session_id)->session_id;
cmd_done.status = vidc_map_hal_err_status((u32)pkt->error_type);
cmd_done.data = &session_init_done;
if (!cmd_done.status) {
cmd_done.status = vidc_hal_process_sess_init_done_prop_read(
pkt, &cmd_done);
}
cmd_done.size = sizeof(struct vidc_hal_session_init_done);
device->callback(SESSION_INIT_DONE, &cmd_done);
}
static void hal_process_session_load_res_done(struct hal_device *device,
struct hfi_msg_session_load_resources_done_packet *pkt)
{
struct msm_vidc_cb_cmd_done cmd_done;
HAL_MSG_LOW("RECEIVED:SESSION_LOAD_RESOURCES_DONE");
if (sizeof(struct hfi_msg_session_load_resources_done_packet) !=
pkt->size) {
HAL_MSG_ERROR("hal_process_session_load_res_done:"
" bad packet size: %d", pkt->size);
return;
}
memset(&cmd_done, 0, sizeof(struct msm_vidc_cb_cmd_done));
cmd_done.device_id = device->device_id;
cmd_done.session_id =
((struct hal_session *) pkt->session_id)->session_id;
cmd_done.status = vidc_map_hal_err_status((u32)pkt->error_type);
cmd_done.data = NULL;
cmd_done.size = 0;
device->callback(SESSION_LOAD_RESOURCE_DONE, &cmd_done);
}
static void hal_process_session_flush_done(struct hal_device *device,
struct hfi_msg_session_flush_done_packet *pkt)
{
struct msm_vidc_cb_cmd_done cmd_done;
HAL_MSG_LOW("RECEIVED:SESSION_FLUSH_DONE");
if (sizeof(struct hfi_msg_session_flush_done_packet) != pkt->size) {
HAL_MSG_ERROR("hal_process_session_flush_done: "
"bad packet size: %d", pkt->size);
return;
}
memset(&cmd_done, 0, sizeof(struct msm_vidc_cb_cmd_done));
cmd_done.device_id = device->device_id;
cmd_done.session_id =
((struct hal_session *) pkt->session_id)->session_id;
cmd_done.status = vidc_map_hal_err_status((u32)pkt->error_type);
cmd_done.data = (void *) pkt->flush_type;
cmd_done.size = sizeof(u32);
device->callback(SESSION_FLUSH_DONE, &cmd_done);
}
static void hal_process_session_etb_done(struct hal_device *device,
struct hfi_msg_session_empty_buffer_done_packet *pkt)
{
struct msm_vidc_cb_data_done data_done;
HAL_MSG_LOW("RECEIVED:SESSION_ETB_DONE");
if (!pkt || pkt->size !=
sizeof(struct hfi_msg_session_empty_buffer_done_packet)) {
HAL_MSG_ERROR("hal_process_session_etb_done:bad_pkt_size");
return;
}
memset(&data_done, 0, sizeof(struct msm_vidc_cb_data_done));
data_done.device_id = device->device_id;
data_done.session_id =
((struct hal_session *) pkt->session_id)->session_id;
data_done.status = vidc_map_hal_err_status((u32) pkt->error_type);
data_done.size = sizeof(struct msm_vidc_cb_data_done);
data_done.clnt_data = (void *)pkt->input_tag;
data_done.input_done.offset = pkt->offset;
data_done.input_done.filled_len = pkt->filled_len;
data_done.input_done.packet_buffer = pkt->packet_buffer;
device->callback(SESSION_ETB_DONE, &data_done);
}
static void hal_process_session_ftb_done(struct hal_device *device,
void *msg_hdr)
{
struct msm_vidc_cb_data_done data_done;
struct hfi_msg_session_fill_buffer_done_compressed_packet *pack =
(struct hfi_msg_session_fill_buffer_done_compressed_packet *) msg_hdr;
u32 is_decoder = ((struct hal_session *)pack->session_id)->is_decoder;
struct hal_session *session;
if (!msg_hdr) {
HAL_MSG_ERROR("Invalid Params in %s", __func__);
return;
}
session = (struct hal_session *)
((struct hal_session *) pack->session_id)->session_id;
HAL_MSG_ERROR("RECEIVED:SESSION_FTB_DONE");
memset(&data_done, 0, sizeof(struct msm_vidc_cb_data_done));
if (is_decoder == 0) {
struct hfi_msg_session_fill_buffer_done_compressed_packet *pkt =
(struct hfi_msg_session_fill_buffer_done_compressed_packet *)
msg_hdr;
if (sizeof(struct
hfi_msg_session_fill_buffer_done_compressed_packet)
!= pkt->size) {
HAL_MSG_ERROR("%s: bad_pkt_size", __func__);
return;
} else if (pkt->error_type != HFI_ERR_NONE) {
HAL_MSG_ERROR("%s: got buffer back with error %x",
__func__, pkt->error_type);
/* Proceed with the FBD */
}
data_done.device_id = device->device_id;
data_done.session_id = (u32) session;
data_done.status = vidc_map_hal_err_status((u32)
pkt->error_type);
data_done.size = sizeof(struct msm_vidc_cb_data_done);
data_done.clnt_data = (void *) pkt->input_tag;
data_done.output_done.timestamp_hi = pkt->timestamp_hi;
data_done.output_done.timestamp_lo = pkt->timestamp_lo;
data_done.output_done.flags1 = pkt->flags;
data_done.output_done.mark_target = pkt->mark_target;
data_done.output_done.mark_data = pkt->mark_data;
data_done.output_done.stats = pkt->stats;
data_done.output_done.offset1 = pkt->offset;
data_done.output_done.alloc_len1 = pkt->alloc_len;
data_done.output_done.filled_len1 = pkt->filled_len;
data_done.output_done.picture_type = pkt->picture_type;
data_done.output_done.packet_buffer1 = pkt->packet_buffer;
data_done.output_done.extra_data_buffer =
pkt->extra_data_buffer;
} else if (is_decoder == 1) {
struct hfi_msg_session_fbd_uncompressed_plane0_packet *pkt =
(struct hfi_msg_session_fbd_uncompressed_plane0_packet *)
msg_hdr;
if (sizeof(struct
hfi_msg_session_fbd_uncompressed_plane0_packet)
> pkt->size) {
HAL_MSG_ERROR("hal_process_session_ftb_done:"
"bad_pkt_size");
return;
}
data_done.device_id = device->device_id;
data_done.session_id = (u32) session;
data_done.status = vidc_map_hal_err_status((u32)
pkt->error_type);
data_done.size = sizeof(struct msm_vidc_cb_data_done);
data_done.clnt_data = (void *)pkt->input_tag;
data_done.output_done.stream_id = pkt->stream_id;
data_done.output_done.view_id = pkt->view_id;
data_done.output_done.timestamp_hi = pkt->timestamp_hi;
data_done.output_done.timestamp_lo = pkt->timestamp_lo;
data_done.output_done.flags1 = pkt->flags;
data_done.output_done.mark_target = pkt->mark_target;
data_done.output_done.mark_data = pkt->mark_data;
data_done.output_done.stats = pkt->stats;
data_done.output_done.alloc_len1 = pkt->alloc_len;
data_done.output_done.filled_len1 = pkt->filled_len;
data_done.output_done.offset1 = pkt->oofset;
data_done.output_done.frame_width = pkt->frame_width;
data_done.output_done.frame_height = pkt->frame_height;
data_done.output_done.start_xCoord = pkt->start_xCoord;
data_done.output_done.start_yCoord = pkt->start_yCoord;
data_done.output_done.input_tag1 = pkt->input_tag1;
data_done.output_done.picture_type = pkt->picture_type;
data_done.output_done.packet_buffer1 = pkt->packet_buffer;
data_done.output_done.extra_data_buffer =
pkt->extra_data_buffer;
if (pkt->stream_id == 0)
data_done.output_done.buffer_type = HAL_BUFFER_OUTPUT;
else if (pkt->stream_id == 1)
data_done.output_done.buffer_type = HAL_BUFFER_OUTPUT2;
}
device->callback(SESSION_FTB_DONE, &data_done);
}
static void hal_process_session_start_done(struct hal_device *device,
struct hfi_msg_session_start_done_packet *pkt)
{
struct msm_vidc_cb_cmd_done cmd_done;
HAL_MSG_LOW("RECEIVED:SESSION_START_DONE");
if (!pkt || pkt->size !=
sizeof(struct hfi_msg_session_start_done_packet)) {
HAL_MSG_ERROR("hal_process_session_start_done:"
"bad packet/packet size: %d", pkt->size);
return;
}
memset(&cmd_done, 0, sizeof(struct msm_vidc_cb_cmd_done));
cmd_done.device_id = device->device_id;
cmd_done.session_id =
((struct hal_session *) pkt->session_id)->session_id;
cmd_done.status = vidc_map_hal_err_status((u32)pkt->error_type);
cmd_done.data = NULL;
cmd_done.size = 0;
device->callback(SESSION_START_DONE, &cmd_done);
}
static void hal_process_session_stop_done(struct hal_device *device,
struct hfi_msg_session_stop_done_packet *pkt)
{
struct msm_vidc_cb_cmd_done cmd_done;
HAL_MSG_LOW("RECEIVED:SESSION_STOP_DONE");
if (!pkt || pkt->size !=
sizeof(struct hfi_msg_session_stop_done_packet)) {
HAL_MSG_ERROR("hal_process_session_stop_done:"
"bad packet/packet size: %d", pkt->size);
return;
}
memset(&cmd_done, 0, sizeof(struct msm_vidc_cb_cmd_done));
cmd_done.device_id = device->device_id;
cmd_done.session_id =
((struct hal_session *) pkt->session_id)->session_id;
cmd_done.status = vidc_map_hal_err_status((u32)pkt->error_type);
cmd_done.data = NULL;
cmd_done.size = 0;
device->callback(SESSION_STOP_DONE, &cmd_done);
}
static void hal_process_session_rel_res_done(struct hal_device *device,
struct hfi_msg_session_release_resources_done_packet *pkt)
{
struct msm_vidc_cb_cmd_done cmd_done;
HAL_MSG_LOW("RECEIVED:SESSION_RELEASE_RESOURCES_DONE");
if (!pkt || pkt->size !=
sizeof(struct hfi_msg_session_release_resources_done_packet)) {
HAL_MSG_ERROR("hal_process_session_rel_res_done:"
"bad packet/packet size: %d", pkt->size);
return;
}
memset(&cmd_done, 0, sizeof(struct msm_vidc_cb_cmd_done));
cmd_done.device_id = device->device_id;
cmd_done.session_id =
((struct hal_session *) pkt->session_id)->session_id;
cmd_done.status = vidc_map_hal_err_status((u32)pkt->error_type);
cmd_done.data = NULL;
cmd_done.size = 0;
device->callback(SESSION_RELEASE_RESOURCE_DONE, &cmd_done);
}
static void hal_process_session_end_done(struct hal_device *device,
struct hfi_msg_sys_session_end_done_packet *pkt)
{
struct msm_vidc_cb_cmd_done cmd_done;
struct list_head *curr, *next;
struct hal_session *sess_close;
HAL_MSG_LOW("RECEIVED:SESSION_END_DONE");
if (!pkt || pkt->size !=
sizeof(struct hfi_msg_sys_session_end_done_packet)) {
HAL_MSG_ERROR("hal_process_session_end_done: "
"bad packet/packet size: %d", pkt->size);
return;
}
list_for_each_safe(curr, next, &device->sess_head) {
sess_close = list_entry(curr, struct hal_session, list);
HAL_MSG_MEDIUM("deleted the session: 0x%x",
sess_close->session_id);
list_del(&sess_close->list);
kfree(sess_close);
}
memset(&cmd_done, 0, sizeof(struct msm_vidc_cb_cmd_done));
cmd_done.device_id = device->device_id;
cmd_done.session_id =
((struct hal_session *) pkt->session_id)->session_id;
cmd_done.status = vidc_map_hal_err_status((u32)pkt->error_type);
cmd_done.data = NULL;
cmd_done.size = 0;
device->callback(SESSION_END_DONE, &cmd_done);
}
static void hal_process_msg_packet(struct hal_device *device,
struct vidc_hal_msg_pkt_hdr *msg_hdr)
{
if (!device || !msg_hdr || msg_hdr->size <
VIDC_IFACEQ_MIN_PKT_SIZE) {
HAL_MSG_ERROR("hal_process_msg_packet:bad"
"packet/packet size: %d", msg_hdr->size);
return;
}
HAL_MSG_INFO("Received: 0x%x in %s", msg_hdr->packet, __func__);
switch (msg_hdr->packet) {
case HFI_MSG_EVENT_NOTIFY:
hal_process_event_notify(device,
(struct hfi_msg_event_notify_packet *) msg_hdr);
break;
case HFI_MSG_SYS_INIT_DONE:
hal_process_sys_init_done(device,
(struct hfi_msg_sys_init_done_packet *)
msg_hdr);
break;
case HFI_MSG_SYS_SESSION_INIT_DONE:
hal_process_session_init_done(device,
(struct hfi_msg_sys_session_init_done_packet *)
msg_hdr);
break;
case HFI_MSG_SYS_SESSION_END_DONE:
hal_process_session_end_done(device,
(struct hfi_msg_sys_session_end_done_packet *)
msg_hdr);
break;
case HFI_MSG_SESSION_LOAD_RESOURCES_DONE:
hal_process_session_load_res_done(device,
(struct hfi_msg_session_load_resources_done_packet *)
msg_hdr);
break;
case HFI_MSG_SESSION_START_DONE:
hal_process_session_start_done(device,
(struct hfi_msg_session_start_done_packet *)
msg_hdr);
break;
case HFI_MSG_SESSION_STOP_DONE:
hal_process_session_stop_done(device,
(struct hfi_msg_session_stop_done_packet *)
msg_hdr);
break;
case HFI_MSG_SESSION_EMPTY_BUFFER_DONE:
hal_process_session_etb_done(device,
(struct hfi_msg_session_empty_buffer_done_packet *)
msg_hdr);
break;
case HFI_MSG_SESSION_FILL_BUFFER_DONE:
hal_process_session_ftb_done(device, msg_hdr);
break;
case HFI_MSG_SESSION_FLUSH_DONE:
hal_process_session_flush_done(device,
(struct hfi_msg_session_flush_done_packet *)
msg_hdr);
break;
case HFI_MSG_SESSION_PROPERTY_INFO:
hal_process_session_prop_info(device,
(struct hfi_msg_session_property_info_packet *)
msg_hdr);
break;
case HFI_MSG_SESSION_RELEASE_RESOURCES_DONE:
hal_process_session_rel_res_done(device,
(struct hfi_msg_session_release_resources_done_packet *)
msg_hdr);
break;
default:
HAL_MSG_ERROR("UNKNOWN_MSG_TYPE : %d", msg_hdr->packet);
break;
}
}
void vidc_hal_response_handler(struct hal_device *device)
{
u8 packet[VIDC_IFACEQ_MED_PKT_SIZE];
HAL_MSG_INFO("############vidc_hal_response_handler\n");
if (device) {
while (!vidc_hal_iface_msgq_read(device, packet)) {
hal_process_msg_packet(device,
(struct vidc_hal_msg_pkt_hdr *) packet);
}
} else {
HAL_MSG_ERROR("SPURIOUS_INTERRUPT");
}
}

View File

@@ -0,0 +1,103 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef __VIDCHALIO_H__
#define __VIDCHALIO_H__
#include <linux/io.h>
#define VIDC_VBIF_BASE_OFFS 0x00080000
#define VIDC_VBIF_VERSION (VIDC_VBIF_BASE_OFFS + 0x00)
#define VIDC_VBIF_ADDR_TRANS_EN (VIDC_VBIF_BASE_OFFS + 0x10)
#define VIDC_VBIF_AT_OLD_BASE (VIDC_VBIF_BASE_OFFS + 0x14)
#define VIDC_VBIF_AT_OLD_HIGH (VIDC_VBIF_BASE_OFFS + 0x18)
#define VIDC_VBIF_AT_NEW_BASE (VIDC_VBIF_BASE_OFFS + 0x20)
#define VIDC_VBIF_AT_NEW_HIGH (VIDC_VBIF_BASE_OFFS + 0x28)
#define VIDC_CPU_BASE_OFFS 0x000C0000
#define VIDC_CPU_CS_BASE_OFFS (VIDC_CPU_BASE_OFFS + 0x00012000)
#define VIDC_CPU_IC_BASE_OFFS (VIDC_CPU_BASE_OFFS + 0x0001F000)
#define VIDC_CPU_CS_REMAP_OFFS (VIDC_CPU_CS_BASE_OFFS + 0x00)
#define VIDC_CPU_CS_TIMER_CONTROL (VIDC_CPU_CS_BASE_OFFS + 0x04)
#define VIDC_CPU_CS_A2HSOFTINTEN (VIDC_CPU_CS_BASE_OFFS + 0x10)
#define VIDC_CPU_CS_A2HSOFTINTENCLR (VIDC_CPU_CS_BASE_OFFS + 0x14)
#define VIDC_CPU_CS_A2HSOFTINT (VIDC_CPU_CS_BASE_OFFS + 0x18)
#define VIDC_CPU_CS_A2HSOFTINTCLR (VIDC_CPU_CS_BASE_OFFS + 0x1C)
#define VIDC_CPU_CS_SCIACMD (VIDC_CPU_CS_BASE_OFFS + 0x48)
/* HFI_CTRL_STATUS */
#define VIDC_CPU_CS_SCIACMDARG0 (VIDC_CPU_CS_BASE_OFFS + 0x4C)
#define VIDC_CPU_CS_SCIACMDARG0_BMSK 0xff
#define VIDC_CPU_CS_SCIACMDARG0_SHFT 0x0
#define VIDC_CPU_CS_SCIACMDARG0_HFI_CTRL_ERROR_STATUS_BMSK 0xfe
#define VIDC_CPU_CS_SCIACMDARG0_HFI_CTRL_ERROR_STATUS_SHFT 0x1
#define VIDC_CPU_CS_SCIACMDARG0_HFI_CTRL_INIT_STATUS_BMSK 0x1
#define VIDC_CPU_CS_SCIACMDARG0_HFI_CTRL_INIT_STATUS_SHFT 0x0
/* HFI_QTBL_INFO */
#define VIDC_CPU_CS_SCIACMDARG1 (VIDC_CPU_CS_BASE_OFFS + 0x50)
/* HFI_QTBL_ADDR */
#define VIDC_CPU_CS_SCIACMDARG2 (VIDC_CPU_CS_BASE_OFFS + 0x54)
/* HFI_VERSION_INFO */
#define VIDC_CPU_CS_SCIACMDARG3 (VIDC_CPU_CS_BASE_OFFS + 0x58)
#define VIDC_CPU_IC_IRQSTATUS (VIDC_CPU_IC_BASE_OFFS + 0x00)
#define VIDC_CPU_IC_FIQSTATUS (VIDC_CPU_IC_BASE_OFFS + 0x04)
#define VIDC_CPU_IC_RAWINTR (VIDC_CPU_IC_BASE_OFFS + 0x08)
#define VIDC_CPU_IC_INTSELECT (VIDC_CPU_IC_BASE_OFFS + 0x0C)
#define VIDC_CPU_IC_INTENABLE (VIDC_CPU_IC_BASE_OFFS + 0x10)
#define VIDC_CPU_IC_INTENACLEAR (VIDC_CPU_IC_BASE_OFFS + 0x14)
#define VIDC_CPU_IC_SOFTINT (VIDC_CPU_IC_BASE_OFFS + 0x18)
#define VIDC_CPU_IC_SOFTINT_H2A_BMSK 0x8000
#define VIDC_CPU_IC_SOFTINT_H2A_SHFT 0xF
#define VIDC_CPU_IC_SOFTINTCLEAR (VIDC_CPU_IC_BASE_OFFS + 0x1C)
/*---------------------------------------------------------------------------
* MODULE: vidc_wrapper
*--------------------------------------------------------------------------*/
#define VIDC_WRAPPER_BASE_OFFS 0x000E0000
#define VIDC_WRAPPER_HW_VERSION (VIDC_WRAPPER_BASE_OFFS + 0x00)
#define VIDC_WRAPPER_CLOCK_CONFIG (VIDC_WRAPPER_BASE_OFFS + 0x04)
#define VIDC_WRAPPER_INTR_STATUS (VIDC_WRAPPER_BASE_OFFS + 0x0C)
#define VIDC_WRAPPER_INTR_STATUS_A2HWD_BMSK 0x10
#define VIDC_WRAPPER_INTR_STATUS_A2HWD_SHFT 0x4
#define VIDC_WRAPPER_INTR_STATUS_A2H_BMSK 0x4
#define VIDC_WRAPPER_INTR_STATUS_A2H_SHFT 0x2
#define VIDC_WRAPPER_INTR_MASK (VIDC_WRAPPER_BASE_OFFS + 0x10)
#define VIDC_WRAPPER_INTR_MASK_A2HWD_BMSK 0x10
#define VIDC_WRAPPER_INTR_MASK_A2HWD_SHFT 0x4
#define VIDC_WRAPPER_INTR_MASK_A2H_BMSK 0x4
#define VIDC_WRAPPER_INTR_MASK_A2H_SHFT 0x2
#define VIDC_WRAPPER_INTR_CLEAR (VIDC_WRAPPER_BASE_OFFS + 0x14)
#define VIDC_WRAPPER_INTR_CLEAR_A2HWD_BMSK 0x10
#define VIDC_WRAPPER_INTR_CLEAR_A2HWD_SHFT 0x4
#define VIDC_WRAPPER_INTR_CLEAR_A2H_BMSK 0x4
#define VIDC_WRAPPER_INTR_CLEAR_A2H_SHFT 0x2
#define VIDC_WRAPPER_VBIF_XIN_SW_RESET (VIDC_WRAPPER_BASE_OFFS + 0x18)
#define VIDC_WRAPPER_VBIF_XIN_STATUS (VIDC_WRAPPER_BASE_OFFS + 0x1C)
#define VIDC_WRAPPER_CPU_CLOCK_CONFIG (VIDC_WRAPPER_BASE_OFFS + 0x2000)
#define VIDC_WRAPPER_VBIF_XIN_CPU_SW_RESET \
(VIDC_WRAPPER_BASE_OFFS + 0x2004)
#define VIDC_WRAPPER_AXI_HALT (VIDC_WRAPPER_BASE_OFFS + 0x2008)
#define VIDC_WRAPPER_AXI_HALT_STATUS (VIDC_WRAPPER_BASE_OFFS + 0x200C)
#define VIDC_WRAPPER_CPU_CGC_DIS (VIDC_WRAPPER_BASE_OFFS + 0x2010)
#endif

View File

@@ -1673,6 +1673,84 @@ enum v4l2_mpeg_mfc51_video_force_frame_type {
#define V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_STATIC (V4L2_CID_MPEG_MFC51_BASE+53)
#define V4L2_CID_MPEG_MFC51_VIDEO_H264_NUM_REF_PIC_FOR_P (V4L2_CID_MPEG_MFC51_BASE+54)
/* MPEG-class control IDs specific to the msm_vidc driver */
#define V4L2_CID_MPEG_MSM_VIDC_BASE (V4L2_CTRL_CLASS_MPEG | 0x2000)
#define V4L2_CID_MPEG_VIDC_VIDEO_ENABLE_PICTURE_TYPE \
(V4L2_CID_MPEG_MSM_VIDC_BASE+0)
#define V4L2_CID_MPEG_VIDC_VIDEO_KEEP_ASPECT_RATIO \
(V4L2_CID_MPEG_MSM_VIDC_BASE+1)
#define V4L2_CID_MPEG_VIDC_VIDEO_POST_LOOP_DEBLOCKER_MODE \
(V4L2_CID_MPEG_MSM_VIDC_BASE+2)
#define V4L2_CID_MPEG_VIDC_VIDEO_DIVX_FORMAT \
(V4L2_CID_MPEG_MSM_VIDC_BASE+3)
enum v4l2_mpeg_vidc_video_divx_format_type {
V4L2_MPEG_VIDC_VIDEO_DIVX_FORMAT_4 = 0,
V4L2_MPEG_VIDC_VIDEO_DIVX_FORMAT_5 = 1,
V4L2_MPEG_VIDC_VIDEO_DIVX_FORMAT_6 = 2,
};
#define V4L2_CID_MPEG_VIDC_VIDEO_MB_ERROR_MAP_REPORTING \
(V4L2_CID_MPEG_MSM_VIDC_BASE+4)
#define V4L2_CID_MPEG_VIDC_VIDEO_CONTINUE_DATA_TRANSFER \
(V4L2_CID_MPEG_MSM_VIDC_BASE+5)
#define V4L2_CID_MPEG_VIDC_VIDEO_STREAM_FORMAT (V4L2_CID_MPEG_MSM_VIDC_BASE+6)
enum v4l2_mpeg_vidc_video_stream_format {
V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_STARTCODES = 0,
V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_ONE_NAL_PER_BUFFER = 1,
V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_ONE_BYTE_LENGTH = 2,
V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_TWO_BYTE_LENGTH = 3,
V4L2_MPEG_VIDC_VIDEO_NAL_FORMAT_FOUR_BYTE_LENGTH = 4,
};
#define V4L2_CID_MPEG_VIDC_VIDEO_OUTPUT_ORDER (V4L2_CID_MPEG_MSM_VIDC_BASE+7)
enum v4l2_mpeg_vidc_video_output_order {
V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DISPLAY = 0,
V4L2_MPEG_VIDC_VIDEO_OUTPUT_ORDER_DECODE = 1,
};
#define V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE (V4L2_CID_MPEG_MSM_VIDC_BASE+8)
#define V4L2_CID_MPEG_VIDC_VIDEO_IDR_PERIOD (V4L2_CID_MPEG_MSM_VIDC_BASE+9)
#define V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES (V4L2_CID_MPEG_MSM_VIDC_BASE+10)
#define V4L2_CID_MPEG_VIDC_VIDEO_NUM_B_FRAMES (V4L2_CID_MPEG_MSM_VIDC_BASE+11)
#define V4L2_CID_MPEG_VIDC_VIDEO_REQUEST_IFRAME (V4L2_CID_MPEG_MSM_VIDC_BASE+12)
#define V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL (V4L2_CID_MPEG_MSM_VIDC_BASE+13)
enum v4l2_mpeg_vidc_video_rate_control {
V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_OFF = 0,
V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_VBR_VFR = 1,
V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_VBR_CFR = 2,
V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_CBR_VFR = 3,
V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_CBR_CFR = 4,
};
#define V4L2_CID_MPEG_VIDC_VIDEO_ROTATION (V4L2_CID_MPEG_MSM_VIDC_BASE+14)
enum v4l2_mpeg_vidc_video_rotation {
V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_NONE = 0,
V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_90 = 1,
V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_180 = 2,
V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_270 = 3,
};
#define MSM_VIDC_BASE V4L2_CID_MPEG_MSM_VIDC_BASE
#define V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL (MSM_VIDC_BASE+15)
enum v4l2_mpeg_vidc_h264_cabac_model {
V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL_0 = 0,
V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL_1 = 1,
V4L2_CID_MPEG_VIDC_VIDEO_H264_CABAC_MODEL_2 = 2,
};
#define V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_MODE (MSM_VIDC_BASE+16)
enum v4l2_mpeg_vidc_video_intra_refresh_mode {
V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_NONE = 0,
V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_CYCLIC = 1,
V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_ADAPTIVE = 2,
V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_CYCLIC_ADAPTIVE = 3,
V4L2_CID_MPEG_VIDC_VIDEO_INTRA_REFRESH_RANDOM = 4,
};
#define V4L2_CID_MPEG_VIDC_VIDEO_AIR_MBS (V4L2_CID_MPEG_MSM_VIDC_BASE+17)
#define V4L2_CID_MPEG_VIDC_VIDEO_AIR_REF (V4L2_CID_MPEG_MSM_VIDC_BASE+18)
#define V4L2_CID_MPEG_VIDC_VIDEO_CIR_MBS (V4L2_CID_MPEG_MSM_VIDC_BASE+19)
/* Camera class control IDs */
#define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900)
#define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1)

49
include/media/msm_vidc.h Normal file
View File

@@ -0,0 +1,49 @@
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _MSM_VIDC_H_
#define _MSM_VIDC_H_
#include <linux/videodev2.h>
#include <linux/poll.h>
enum core_id {
MSM_VIDC_CORE_0 = 0,
MSM_VIDC_CORES_MAX,
};
enum session_type {
MSM_VIDC_ENCODER = 0,
MSM_VIDC_DECODER,
MSM_VIDC_MAX_DEVICES,
};
int msm_vidc_open(void *vidc_inst, int core_id, int session_type);
int msm_vidc_close(void *instance);
int msm_vidc_querycap(void *instance, struct v4l2_capability *cap);
int msm_vidc_enum_fmt(void *instance, struct v4l2_fmtdesc *f);
int msm_vidc_s_fmt(void *instance, struct v4l2_format *f);
int msm_vidc_g_fmt(void *instance, struct v4l2_format *f);
int msm_vidc_s_ctrl(void *instance, struct v4l2_control *a);
int msm_vidc_g_ctrl(void *instance, struct v4l2_control *a);
int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
int msm_vidc_prepare_buf(void *instance, struct v4l2_buffer *b);
int msm_vidc_release_buf(void *instance, struct v4l2_buffer *b);
int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b);
int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b);
int msm_vidc_streamon(void *instance, enum v4l2_buf_type i);
int msm_vidc_streamoff(void *instance, enum v4l2_buf_type i);
int msm_vidc_decoder_cmd(void *instance, struct v4l2_decoder_cmd *dec);
int msm_vidc_poll(void *instance, struct file *filp,
struct poll_table_struct *pt);
#endif