Skip to content
  • Rupert Swarbrick's avatar
    Simplify get_partition() implementation · 136d5c17
    Rupert Swarbrick authored
    This function is given a bsize and an mi array and has to figure out
    what partition to use to divide the given bsize in the direction of
    the sizes it finds in the mi array. (Since each block size can be
    reached by only one sequence of partitions, this can be done
    unambiguously)
    
    The previous version was correct, working by looking up entries in the
    partition_lookup array. Unfortunately, that lookup isn't quite enough
    when CONFIG_EXT_PARTITION_TYPES is true, so it then had to do some
    slightly confusing computations to fix things up after the fact.
    
    The new version should be more self-explanatory and doesn't work by
    looking things up in a magic array. It looks up the width and height
    corresponding to bsize and compares them with the width and height
    corresponding to the sb_type at mi_row,mi_col in the mi array. When
    CONFIG_EXT_PARTITION_TYPES is false, this is all you need, and the
    four corresponding cases can be found by a lookup in an array of 4
    elements.
    
    With extended partition types and a sufficiently large block, you have
    to do a bit more searching. For example, if bsize is BLOCK_16X16 and
    the subsize is BLOCK_8X8, the partition might be PARTITION_SPLIT, but
    it might be one of PARTITION_HORZ_A or PARTITION_VERT_A instead. The
    new code adds some comments to explain what's going on.
    
    A nice side-effect of rewriting get_partition in this way is that it
    lets us completely dispense with the partition_lookup array.
    
    The patch also fixes comments for the A/B extended partitions in
    enums.h, which were slightly backwards (a "horizontal split means two
    blocks vertically above one another)
    
    Change-Id: I4b48189103aa63e1859f25a15d7690d53ca7baf5
    136d5c17