function varargout = dspblkupfir(action,varargin)
% DSPBLKUPFIR Mask dynamic dialog function for FIR interpolation block

% Copyright 1995-2000 The MathWorks, Inc.
% $Date: 2000/04/29 22:54:49 $ $Revision: 1.4 $

blk = gcb;    % Cache handle to block

switch action
    
case 'setup'
    % Input arguments for setup case:
    % dspblkupfir('setup', h,L,framing)
    
    h = varargin{1};
    L = varargin{2};

    if(isempty(L))
      str = '???';  % Default display
    else
        str=['x[n/' num2str(L) ']'];
    end

    [M,N] = size(h);
    if (M ~= 1 & N ~= 1)
        error('The filter coefficients must be a non-empty vector');
    end
    if (isempty(L) | L < 1 | fix(L) ~= L)
        error('Interpolation factor must be a positive integer');
    end

    if(~isempty(h) & ~isempty(L))

        % Need to reshuffle the coefficients into phase order
        len = length(h);
        if (rem(len, L) ~= 0)
            nzeros = L - rem(len, L);
            h = [h(:); zeros(nzeros,1)];
        end
        len = length(h);
        nrows = len / L;
        % Re-arrange the coefficient and gain-scale
        h = L * reshape(h, L, nrows).'; 
    end    
    
    varargout = {h,str};
    
otherwise
    error('unhandled case');
end

% end of dspblkupfir.m
